Friday, July 31, 2020

D365 CE Tips: Determine Mobile or Web in D365 CE using JavaScript

If you work with both CE Web and Mobile using Unified Interface, you may need to distinguish mobile client and web client inside your custom JavaScript. For example if you use single web resource for both CE web and CE mobile you have to distinguish both platforms to change your logic according to the platform.

Following code snippets will help you to distinguish platform based on the scenario.

Using GlobalContext

var globalContext = Xrm.Utility.getGlobalContext();
var Client = globalContext.client.getClient();


Using ExecutionContext

var Client = executionContext.context.client.getClient();

Value of Client variable will be “Web” or “Mobile” based on the platform. Hope this tip will be help. Enjoy 😊

No comments:

Post a Comment