Bug - TurboForms Xrm.Page.data.save().then() Errors With ErrorCode "Null", Message "Undefined"
onChange() Calls save(), From Field That Is Invalid
Steps to Reproduce (Turbo Forms, CRM 2015.1, —> CRM 2016.2)
- Form (with or without other required fields) has one field that is empty and required.
- Lose focus on the empty field (“title” in this example), this triggers the Field Notification Icon:
3. Wire up onChange Handler for empty field to call save:
function forceSaveOnChangeOfTitle(){
Xrm.Page.data.save().then(
function () {},
function (error, message) {console.error("Error: " + error + " Message: " + message);}
);
}
- Enter a Value in empty field.
Result:
- Save fails. Calls failure callback with Error Number of “null”, and Message of “undefined”.
- Field Notification disappears, but required message is still displayed in the bottom right:
Known Workarounds:
Set the value of the attribute to itself:
function forceSaveOnChangeOfTitle(){
var title = Xrm.Page.getAttribute("title");
title.setValue(title.getValue());
Xrm.Page.data.save().then(
function () {},
function (error, message) {console.error("Error: " + error + " Message: " + message);}
);
}
Use 1ms Timeout with:
function forceSaveOnChangeOfTitle(){
setTimeout(function() {
Xrm.Page.data.save().then(
function () {},
function (error, message) {console.error("Error: " + error + " Message: " + message);}
);
}, 1);
}