How to Read the current Model-driven App details using client API references

Sending
User Review
0 (0 votes)

Introduction:

In a recent project while working on client-side scriptings, we had come across a requirement where we interact with Dynamics 365 CRM data using WebAPI and query expressions. In most cases, we needed the current Model-driven app AppId to build the WebAPI URLs. We had achieved this by using Dynamics CRM Client API references.

With the help of Client API references, we can read the current Model-driven app details. Please find the Client API references below, using which we can get the current Model-driven app details.

1. getCurrentAppProperties

With the use of getCurrentAppProperties client API reference, we can get the current Model-driven app details. Please find the code below:

var globalContext = Xrm.Utility.getGlobalContext(); globalContext.getCurrentAppProperties().then( function successCallback (appDetails) { alert('App Details found'); }, function errorCallback() { alert('Error'); }); 

client API reference

2. getCurrentAppName

With the use of getCurrentAppName client API reference, we can get the current Model-driven app AppName. Please find the code below:

var globalContext = Xrm.Utility.getGlobalContext(); globalContext.getCurrentAppName().then( function successCallback(appName) { alert(appName); }, function errorCallback() { alert('Error'); }); 

client API reference

3. getCurrentAppUrl

With the use of getCurrentAppUrl client API reference, we can get the current Model-driven app AppUrl. Please find the code below:

client API reference

Conclusion:

In this way, with the help of Client API references we can easily get details of the current Model-driven app.

 




															
AllEscort