Skip to content

Filter Regarding Field to show the specific entities in D365 CRM(CE)

Introduction: In this blog, we will understand how to show specific entities in Regarding Field.

Use Case: In my example, I have created a custom Filed ”regarding type”, which is option set, based on the input from the option set value I have set the Entity Type in the below code:

// JavaScript source code
var formCustomizations = {
    filterRegarding: function (execContext) {
        var formContext = execContext.getFormContext();
        if (formContext.getAttribute("new_regardingtype").getValue() != null) {
            regardingtype = formContext.getAttribute("new_regardingtype").getValue();
            if (regardingtype === 1) {
                formContext.getControl("regardingobjectid").setEntityTypes(["account"]);
            }
            else if (regardingtype === 2) {
                formContext.getControl("regardingobjectid").setEntityTypes(["contact"]);
            }
            else {
                formContext.getControl("regardingobjectid").setEntityTypes(["contact", "account"]);
            }
        }
    }
}
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments