How to Get the AppId of Model Driven App in Dynamics 365 using JavaScript

Hi Everyone,

Today I was working on something and we need to get AppId in JavaScript. We all know it is available on URL and we can get it from there but we cannot really depend on URL as it is generated by Product and it might change.

After quick check, I found that we can easily get AppId using the below code.

  var globalContext = Xrm.Utility.getGlobalContext();
    globalContext.getCurrentAppProperties().then(
        function success(app) {
            console.log(app);
            console.log(app.appId);
        },
        function errorCallback() {
            console.log("Error");
        });

Hope this helps.


Happy 365’ing
Gopinath.

3 thoughts on “How to Get the AppId of Model Driven App in Dynamics 365 using JavaScript

  1. Andrew November 11, 2020 / 1:17 am

    Hi, how would you use that code to get the appId to a variable that you could use? You can see it in the console.log(), but you want to be able to assign the appId to a variable when you are creating the string.

    Like

    • Gopinath November 12, 2020 / 9:27 am

      Hi Andrew,

      Just declare a variable in JavaScript and assign the value as below.

      var vAppId = app.appId;

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s