CRM 2011/2013 – What does setSubmitMode do? and how does it work?

I was getting an error on an IE8 browser

Error:Object doesn’t support property or method ‘setSubmitMode

cannot sumbit

hmm, what does this mean.



When we are bug hunting we have to don are Sherlock holmes deer stalker hats and work out what we know.  So a good place to start is what is SetSubmitMode

Good news is Microsoft has a good explanation, I have pasted the relevant bit below


You can control when data for an attribute is submitted when a record is created or saved. For example, you may have a field on the form which is only intended to control logic in the form. You are not interested in capturing the data in it. You might set it so that the data is not saved. Or you may have a Plugin registered that depends on the value always being included. You may want to set the attribute so that it will always be included. Attributes that do not get updated after the initial save of the record, such as createdby, are set so that they will not be submitted on save. To force an attribute value to be submitted whether it has changed or not, use the setSubmitMode function with the mode parameter set to “always”.

When using setSubmitMode you have three options:

  • always: The value is always submitted.
  • never: The value is never submitted. When this option is set, data cannot be edited for any fields in the form for this attribute.
  • dirty (default): The value is submitted on create if it is not null, and on save only when it is changed.


Type: StringOne of the following values:

  • always: The data is always sent with a save.
  • never: The data is never sent with a save. When this is used the field(s) in the form for this attribute cannot be edited.
  • dirty: Default behavior. The data is sent with the save when it has changed.

How SetSubmitMode works

Ahh it’s coming back to me.  The main time I use SetSubmitMode is when I am using read only fields.  I shall explain the Hosk understanding of how CRM saves fields.

CRM likes to be as efficient as possible, so rather than saving all the fields you press the save button or the auto save kicks in CRM 2013, it only saves the fields which have been changed.

All the fields on a CRM form have sumbit value.  When a field is changed, CRM will set the field to dirty.  When a save button is pressed CRM will send all the fields which are dirty to the server to be saved.

Client Side to Server Side

The dirty value is what controls what is sent from the Client side (GUI – Form) to the server side (workflows/plugins).  When a field gets changed, the submit metadata gets set to dirty.  When the next save event happens all those fields get sent to the server and the plugins and workflows which are triggered by the change of that entity and fields.

The plugins/workflows will change/use the data before it gets saved to the database (which might trigger more plugins and workflows)


Read Only rite of passage

There comes a moment in every CRM developers life when they make the transition from baby developer to toddler developer.

They will have some fields on the form, the fields will be set with a value but they will not save!  WHY WHY WHY you can hear them howl in frustration, I’m setting the value.

The baby CRM developer will pop on his deer stalker hat to diagnose the problem and will notice the field is read only?

They will then search the internet and probably come to a page like this

CRM 2011 – how to update read only fields with Javascript

The problem is read only fields are not considered for saving and CRM doesn’t automatically set the submit value to dirty when they are changed.  When the submit value isn’t dirty the fields never get sent to the server to be saved.

In this situation you have to use the SetSubmitMode to change the submit value to dirty, which means the field will be saved.

Back to the Error

Let me remind you again of the error

cannot sumbit

So the error was complaining about an object not supporting the setSubmitMode.

I tracked down the error too the code below

var attributes =;

for (var i in attributes) {
{ attributes[i].setSubmitMode(“never”); }



We can see it’s retrieving all the fields and setting the setSubmitMode.  I pressed F12 and got the Javascript debugger up.  I watched the i variable count up to 19 fields and then change to the value of “indexOf“.  So the error was instead of using a number to use to get the correct field in the array of fields it used a string, which basically made it go mental and throw an error.

It was trying to do this

attributes[“indexOf”].setSubmitMode(“never”); }

To fix this I checked to see if the i variable was a number by doing an isNAN


for (var i in attributes) {
if (!isNaN(i)) {


Thank fully this resolved the issue because I didn’t have any other ideas and I don’t really understand why this error only happens in IE8.

How to recreate it

I didn’t install IE8 (what madman would do such a thing!) instead when I was in the F12 Javascript Debugger.  On the top menu there is button called Browser Mode and this enabled me to view the CRM page in IE 8 browser.

You can read more about it here

6 thoughts on “CRM 2011/2013 – What does setSubmitMode do? and how does it work?

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s