Below code are used to get the current Dynamics 365 CRM Model Driven App Name.
Xrm.Utility.getGlobalContext().getCurrentAppName().then(
function (appName) {
},
function (error) {
}
);
Example:
Read the current Model Driven App Name, If App Name is Sales Hub then Contact entity/table Account Name(lookup) field make the mandatory, otherwise not.
function getCurrentModelDrivenAppName(executionContext)
{
let formContext = executionContext.getFormContext();
Xrm.Utility.getGlobalContext().getCurrentAppName().then(
function (appName)
{
if (appName == "Sales Hub")
{
formContext.getAttribute("parentcustomerid").setRequiredLevel("required");
}
else
{
formContext.getAttribute("parentcustomerid").setRequiredLevel("none");
}
},
function (error)
{
alert("error " + error.message);
});
}
No comments:
Post a Comment