Do we still need to use setSubmitMode to save the value of a read-only attribute?

By | January 8, 2020


Before we get to the answer to this question, first we will see what the use of setSubmitMode is. The setSubmitMode is a method to set whether data from the attribute will be submitted when the record is saved.

This method accepts one of the below values as a parameter;

  • Always: If we set as ‘’always’’ then data of the attribute will always be sent with a save. Data will be saved always even though the attribute is not dirty.
  • Never: If we set as ‘’never’’ then data of the attribute will never be sent with a save. Data will not be saved even when value/data of the field is changed. We use this mode when we don’t want to capture the value but want to trigger some logic on change of the attribute.
  • Dirty: This mode will send the data with a save or when it has been changed.

If we ask any CRM developer what is the use of setSubmitMode method along with the aforementioned details we will get one more answer i.e. we have to use setSubmitMode with ‘’always’’ to save the value of read-only attribute. If we have a read-only attribute on the form and want to set the value through script then we would need to write an additional line of code i.e. setSubmitMode with ‘’always’’ parameter.



But this have been changed from Dynamics 365 9.x version. Now, we don’t need to use this additional line of code to send the value of the read-only attribute. This is explained in the below link where you can see we are copying the value of “Credit” attribute to read-only “Available Credit” attribute.

And the below code is used on change of “Credit” attribute:

function calculateCredit(context) {

    try {

        var formContext = context.getFormContext();

        var credit = formContext.getAttribute("creditlimit").getValue();


    } catch (error) {

        throw new Error(error.message);




So basically, the value of the read-only field can be saved without writing an additional setSubmitMode method. Moreover, this also works in both classic web and Unified interface.

Generate Your Own New Leads Within Microsoft Dynamics 365 CRM

Contact us for a demo to know more about how Maplytics can help you to generate new leads from within Microsoft Dynamics 365 CRM.

Maplytics is a 5-star rated, preferred business app on the Microsoft AppSource that is Certified for Microsoft Dynamics 365 (CfMD) and comes with powerful features like Appointment Planning, Sales Routing, Territory Management, Heat Maps, Geo-analytical Dashboards and more that empower organizations to add more value to their CRM data, improve sales & service processes, and achieve high ROI.

Get your free trial from our Website or Microsoft AppSource!

‘If data is the new oil, location intelligence is ??”