Quick and easy function to save all Read only fields

One thing that has always irritated me to no end about CRM is the fact that it doesn’t write read only fields to the database when saving.  I mean c’mon!  There is is extensive scripting ability and API, and numerous reasons why you would want to have a field that is only able to be changed by the system and not the end user.

OK, /rant.

Here is a handy bit of script I use a lot in CRM 2011 to run through and save everything that is read only.  The get uses a delegate function to return an array of all read only fields (fields where getDisabled() equals true) and then runs through and sets the submit mode to always.  This forces the application to write the field value to the database after all.

function saveReadOnly()


    var nonSubmitFields = Xrm.Page.ui.controls.get(function (control, index){return control.getDisabled() == true;});

    for (i = 0; i < nonSubmitFields.length; i++)







Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: