Thursday, December 22, 2011

Force Submit in MS CRM 2011

As we were doing forceSubmit() in MS CRM 4.0, if there is a change in the field, by checking isDirty().
in MS CRM 2011 its bit different, as follow

//set the value to the attribute
        Xrm.Page.data.entity.attributes.get("<attributeName>").setValue("Value");
        Xrm.Page.data.entity.attributes.get("<attributeName>").setSubmitMode("dirty");

Other values for setSubmitMode() are
dirty : it will submit only if the value of the attribute has changed
always : it will submit the attribute's value always.
none : it will not submit at all

The default value for editable fields is ‘dirty’, which means that the value will be submitted to the server only when that data value is changed. For fields that do not get updated after the initial save of the record, such as createby, the default value is “never”. 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”.
Thanks,
yes.sudhanshu

No comments:

Post a Comment