How to Get the AppId of a Dynamics 365 Power App using JavaScript

Leave a comment

This one’s pretty useful when you’re building out URLs in your JavaScript and you are using the AppId of your model-driven Power App / Dynamics 365. You don’t ever want to hardcode these values, and you will need to move your code across your environments at some point so getting this value programmatically is the best approach.

If you prefer to watch a video on this, check out the video on my YouTube Channel:

In the account page below, we see in the URL the AppId of our App – 0da29984-d407-ea11-a81e-000d3a35b116:

 Now, let’s go into debug in the browser and run the code below (of course, you can run this anywhere you need to):

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

When we run this, we see in passing a variable into the first parameter (appId), it gives us several pieces of information, including the appId, displayName, uniqueName, url, webResourceId, webResourceName, welcomePageId and welcomePageName:

That’s it. Use any field you want, e.g. app.appId:



Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube


Leave a Reply

Your email address will not be published. Required fields are marked *