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"]);
}
}
}
}

