{Power 2021} Get current App details in Model Driven App and D365 client-side scripts

Sending
User Review
0 (0 votes)

In a recent project there was a need to know Model driven App name in client side script.

We can achieve the requirement using following script.

In this example I have alerted App details on Load of a custom entity titled “Visit” under a Model driven App called “Visitor management”.

Here is the output:

clip_image002

Here is the script:

function onLoadApp()

{
var globalContext = Xrm.Utility.getGlobalContext();
globalContext.getCurrentAppProperties().
then(

function successCallback(app)

{
var message = “App Display name: ” + app.displayName + “\nApp name: ” + app.uniqueName + “\nApp Id: ” + app.appId;
var messageString =
{
confirmButtonLabel: “Ok”,
text: message
};

var messageAlertOption =
{
height: 120,
width: 260
};

Xrm.Navigation.openAlertDialog(messageString, messageAlertOption);

},

function errorCallback()

{ console.log(“Error”);

}

);

}

Other details that are accessible in the app object are mentioned below:

· appId

· displayName

· uniqueName

· url

· webResourceId

· webResourceName

· welcomePageId

· welcomePageName

Hope it helps and Power 365ing as usual!

Other ways to learn with me:

clip_image004

Any problem in Power Platform or Dynamics 365 – end user, Microsoft partner or an individual?

Problem Area – Technical, Functional, Training, Development or consulting?

I am here to help, get in touch here: Click here

clip_image006