Check mandatory fields using JavaScript in Dynamics CE/CRM

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

Filed under: Blog

No comment yet, add your voice below!

Add a Comment

Your email address will not be published. Required fields are marked *

Comment *
Name *
Email *

This site uses Akismet to reduce spam. Learn how your comment data is processed.