Skip to content

Make the field required using JavaScript in D365 CE

In this blog, we will learn how to make a column(field) required using JavaScript in D365 CE(CRM).

Syntax:

formContext.getAttribute(columnName).setRequiredLevel(requirementLevel)

PARAMETER:

Code:

var formCustomizations = {
    setFieldRequired: function (executionContext) {
        let formContext = executionContext.getFormContext();
          
        //this will make the field required
        formContext.getAttribute("avt_date").setRequiredLevel("required");

        //this will make the field recommended
        formContext.getAttribute("avt_customer").setRequiredLevel("recommended");

        //this will make the field not required
        formContext.getAttribute("avt_title").setRequiredLevel("none");
    }
}

Result:

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments