I use the following way to set values of form fields programmatically.
$w.('#fieldName').value = 'some data'
I have several UserInput fields. They are all connected to a database collection. If I enter data manually into all of the fields, they all get stored in the database. If I use code (like stated above) to enter data to some fields - those fields will not get stored while other fields (with manually entered data) will get stored.
I used console.log() to see if values were set the same way for the manually entered fields and the programmatically entered fields - it looks the same.
I tried manually appending a character to the programmatically entered fields and then the entire data (programmatically entered and manually entered) was stored.
I am guessing that there is some kind of an attribute on each field that indicates whether it was changed or not, and setting the values using code does not trigger the attribute change to reflect the true state of the field.
I hope I am missing something - like a click on some attribute or something.