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

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.

For more great blogs click here

About the Author:

Inogic is a Microsoft Gold Partner and a leading Dynamics 365 CRM ISV since 2007 with exclusive focus on providing innovative apps and services on Dynamics 365 CRM/Power Platform. Its flagship product Maplytics™a 5 star rated Preferred App on Microsoft AppSource, is a market-leading maps integration app for Dynamics 365 CRM and Dataverse. Inogic is renowned for its 15 Microsoft Preferred Productivity Apps on Microsoft AppSource. Be it App Integrations like MailChimp Integration, Subscription and Recurring Billing ManagementQuickBooks Integration, Auto Tax Calculator, streamlining Document Management in Dynamics 365 CRM/CE with Attach2DynamicsSharePoint Security Sync improving productivity with Click2CloneClick2ExportClick2UndoAlerts4DynamicsLead Assignment and Distribution AutomationUser Adoption MonitorGamifics365, or simply visual representation of data using Visualization Apps Kanban BoardMap My Relationships Inogic has always been a hub of distinct and innovative apps for Dynamics 365 CRM / Dataverse. Contributing to the community, Inogic Blogs are very popular for their regular high-quality tips and tricks on all things Dynamics 365 CRM / Power Platform. To learn more about how Inogic can help you in enhancing your Dynamics 365 CRM user experience, visit https://www.inogic.com/ or contact crm@inogic.com

Reference:

Inogic. (2022). Execute Commands Programmatically in PCF Dataset Component. Available at: https://www.inogic.com/blog/2022/03/how-to-read-the-current-model-driven-app-details-using-client-api-references/[Accessed: 13th April 2022].

Share this on...

Rate this Post:

Share:

Topics:

API

Tags: