Hi,
We have a scenario where all mandatory fields have to be ignored during an operation and save should be triggered. We are doing this in JavaScript with the below code:
clearAllSections();
Xrm.Page.data.entity.save();
clearAllSections = function () {
try {
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes) {
Xrm.Page.getAttribute(attributes[i].getName()).setRequiredLevel("none");
}
}
catch (e) {
alert("Error clearing requirements in field : " + attributes[i].getName());
}
}
System is not performing the save operation and is throwing message to fill the mandatory fields. When I debug the JS and check getRequiredLevel() of those fields, it is set to "none" itself.
Any idea why system is still asking to fill the mandatory fields even though requiredLevel is none? The fields are Optional and are set as required fields during OnLoad depending on various Business conditions.
*This post is locked for comments
I have the same question (0)