Tuesday, 31 March 2015

Forcing the Save on Read-only Fields

If the value of a filed changes then will always force the save. This get over the issue where read only fields don’t save .

var oldSetValue = Mscrm.AttributeWrapper.prototype.setValue;
Mscrm.AttributeWrapper.prototype.setValue = function(value) {
//   if you are changing the value of a field it should be set to always regardless of access
    if(value != this.getValue())
  {
  this.setSubmitMode("always");
  }
  // Call the function as it would have been called normally:
  oldSetValue.call(this, value);
  // Run stuff after, here.
}

I included it on the form in a separate library called optevia_fieldextentions on the form
You call the SetValue method as normal and it will save regardless if its readonly or not

Xrm.Page.getAttribute('optevia_year2fundingadjustment').setValue(0.00);

No comments:

Post a Comment