Home > Dynamics 365 > Dynamics 365 Mobile Client – Script to get Longitude and Latitude and pin to Maps

Dynamics 365 Mobile Client – Script to get Longitude and Latitude and pin to Maps

With the new Dynamics 365 Mobile client, we got a new API Xrm.Utility.getCurrentPosition which returns the current location coordinates.

This API only works with Mobile Client and referring this in Web Application would cause script error.


We need to Enable User Location setting on the device

  • Go to Settings -> Device Integration Settings


  • Enable “User Content and Location”


Script to get coordinates:

function onload() {
var isCrmForMobile = (Xrm.Page.context.client.getClient() == “Mobile”);

if (isCrmForMobile) {
(function (location) {
Xrm.Utility.alertDialog(“Latitude: ” + location.coords.latitude +
“, Longitude: ” + location.coords.longitude);
function (error) {



HTML File to Read Coordinates and Show in Map



  1. Gayatri
    January 20, 2017 at 10:42 AM

    Hi Rajeev,

    How to get auto generated number sequence for a Expense ID in power app.

    Steps followed :
    1. in D365 created a custom data entity , using table TRVexepnse.
    2. Logged to Power app, created a app using data connection as Dynamics 365 for operations and selected the custom data entity.
    3. I got 3 screen in the app, browse, detailed and edit screens.
    4. While adding new record through app, Expense ID should generate automatically. (App showing error saying Expene no is mandatory)
    5. In APP, Expense field is read only.

    Please suggest how to over come this issue.


  2. Aayush
    November 10, 2017 at 1:28 AM

    But HTML doesn’t works on Phone..An above doesn’t works on web…So basically We can only use it for tablet or is there any way to view it either on web or mobile?

  1. No trackbacks yet.

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 )

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

%d bloggers like this: