I had created a field called arranged by and it was a user lookup which was read only because I didn’t want people to set it, I wanted to set it when someone booked in a date and then fill in the field.
What was happening was I was setting the field, which you can read about here but then it saved but on the reload the field was blank, AGHGHGHGG.
So it turns out that read only fields are not submitted to the database to be saved. Which in one way is good because it means less traffic going up the pipe to the database but very annoying for me who is trying to set the read only value.
So if you want to save a read only field you need to set the SubmitMode to be always, which ensures the value is sent to the database.
Good tip! I have a problem with my onSave function though. I’m using XMLHttpRequest to retrieve related information that I would like to set into my read only field. The function is launched when ever another field is changed (onChange) or when the form is saved (onSave). onChange works just fine, but onSave has no effect. I was wondering could it be that onSave doesn’t wait the execution of the function?
I’m guessing you have solved this on your own some time ago but just for completeness:
If you want to do asynchronous actions in onSave, you have to cancel the default action in the onSave function (ExecutionObj.getEventArgs().preventDefault();) and then do the save in the callback function.
It had tried several other options and workarounds. It’s great you posted this on the Internet!
Huge help! I had the same hair-tearing problem…
Great, works perfectly. Thanks