CRM 2011 – how to update read only fields with Javascript

I have had an annoying problem which had me pulling out my hair in frustration when I was testing some javascript.

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.

I then read this forum question – read only field isn’t updated after javascript save

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.