
I need to include in my JavaScript code, a check/test to detect if it is running on the Unified Interface Website (dynamicsorg.crm.dynamics.com) OR if its running on the Mobile App for IOS or Android.
I see something here https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/173636/how-to-test-the-crm-mobile-application-for-running-javascript?pifragment-97030=1 that talks about that, but the code listed does not seem to run or generate the alert within the mobile app?
What JavaScript code can I use or how can I "detect" if the current app is the D365 Mobile App installed on a Mobile Device OR if it's the Unified Interface/Web?
Hi,
The shared code is deprecated and I think it no longer works. This is an update of the code:
function isMobileClient() {
var client = Xrm.Utility.getGlobalContext().client.getClient();
if (client == "Mobile") {
var alertStrings = { confirmButtonLabel: 'Yes', text: 'This is an alert for Mobile' };
var alertOptions = { height: 120, width: 260 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
function success() {
// perform operations on alert dialog close
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
}
else if (client == "Web") {
var alertStrings = { confirmButtonLabel: 'Yes', text: 'This is an alert for Web' };
var alertOptions = { height: 120, width: 260 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
function success() {
// perform operations on alert dialog close
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
}
}
Web:
Mobile: