Cannot save a disabled control on CRM form
Suppose you have used the following function to “Disable” a field
Method:
Method:
/* * SetDisabledField * To disable/enable field by field id and isDisabled flag * fieldId --> field id * isDisabled --> true or false */ SetDisabledField: function (fieldId, isDisabled) { var fieldID = Xrm.Page.ui.controls.get(fieldId); if (fieldID != null) fieldID.setDisabled(isDisabled); },And you have called the method as:
SetDisabledField('new_revenue', false);Now in case you have changed the value of the field before you disabled it, clicking on save will not include this attribute and as a result the value will not change!
Solution:
Change the submit mode to always will “always” send the attribute into the message and it will be saved regardless:
Xrm.Page.getAttribute('new_revenue').setSubmitMode('always');
From SDK
setSubmitMode
Sets
whether data from the attribute will be submitted when the record is saved.
Attribute
Types:
All
JScript
| |
attributeObj.setSubmitMode()
|
Arguments
Type: String
One
of the following values:
·
always
·
never
·
dirty
Example: The
SDK.AttributeSamples.submitAllOptionsetData function will force all optionset
attributes to be submitted. This is confirmed by checking getDataXml and displaying the result in an
alert.
JScript
| |
SDK.AttributeSamples.submitAllOptionsetData = function () {
var attributes =
Xrm.Page.data.entity.attributes.get(SDK.AttributeSamples.isOptionSet);
for (var i in attributes) {
attributes[i].setSubmitMode("always");
}
alert(Xrm.Page.data.entity.getDataXml());
};
|
No comments:
Post a Comment