Saving Data When A CRM Field is Read-Only With JavaScript (setSubmitMode)

Client Side Programming Jan 21, 2017

Saving data when a CRM field ist read-only is a often requriered use case, when data is fetched by javascript and written in such a field.

Many Developers don’t know in the first place, that if a CRM field is read-only on the client-side you have to set the submit mode of the attribute. Otherwise changes which are made through JavaScript code on the field (e.g. setValue) aren’t stored in the database.

The SubmitMode knows three different values (never, dirty and always), but to make sure that every change is correctly saved you should use the “always” keyword – like on the example shown below.

Xrm.Page.getAttribute("fieldName").setSubmitMode("always");

Learn more about the SubMode on the related MSDN article.

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.