Hi!
I use code to set an input field value to that of another input field.
In preview and on the live site it all works perfectly:
When input A is filled out, input B is filled out with the value of input A.
However, the value of input B never gets saved to the collection - it’s just blank in the database. No matter how I’ve tried to convert string to number, it never saves.
I’m using this code:
export function inputAmount_change(event) { var amount = parseFloat($w(“#inputAmount”).value) $w(“#inputRevenueItem1Amount”).value = amount; }
Going by your post above, it sounds like you are just using code to set a field value, so that is the reason why it is not being saved into your dataset.
Using code to add a value to a input does not make the input trigger that there has been a change to that input and so needs saving, whereas if a user themselves added something to the input it would.
Setting the value of a field in a dataset item does not immediately set that value in the collection that the dataset is connected to. You still need to call the dataset save() function or any other function that performs a save to have the new value reflecting in the collection.
No of course I am running a save() command the field saves to the dataset if I have entered the value myself, but if it entered via code it does not save.
I’ve been looking for this solution for awhile. Just to clarify for others looking for this: I was trying to use a string to calculate a formula, then have the answer sent to the collection.