Check mandatory fields using JavaScript in CE/CRM
This function returns false if there is at least one field is not populated on the form.
Here is the function:
//Checks if all the mandatory fields are populated.
function CheckMandatoryFields(executionContext) {
formContext = executionContext.getFormContext();
var populated = true;
formContext.getAttribute(function (attribute, index) {
if (attribute.getRequiredLevel() == "required") {
if(attribute.getValue() === null) {
populated = false;
}
}
});
return populated;
}
Work Cited:
Original script taken and modified from http://mehmetgunen.com/check-mandatory-fields-using-javascript-in-crm/
No comment yet, add your voice below!