web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

JavaScript to test for Mobile App (IOS/Android)?

(0) ShareShare
ReportReport
Posted on by 1,589

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?

I have the same question (0)
  • Verified answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    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: 

    pastedimage1620050934378v1.png

    Mobile: 

    pastedimage1620051024796v3.png

    Documentation: https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/client#getclient

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans