Get Current Location of Device in D365 CE(CRM) using JavaScript

In this blog, we will look at how we can get the current location of the device with the click of a button.  



Xrm.Device.getCurrentPosition().then(successCallback, errorCallback)


var formCustomizations = {
    getLocation: function (executionContext) {
        var formContext = executionContext;
            function success(location) {
            function (error) {
                Xrm.Navigation.openAlertDialog({ text: error.message });
  • Call the “getLocation” function on button.
  • After doing everything successfully when you will click on a button you will get latitude and longitude.


  1. This method is supported only for mobile clients.
  2. Location setting must be enabled in Dynamics 365 for Phones app

Follow below steps to achieve this:

  • Go to settings
  • click on enable location
  • click on OK to give permission
  1. Dynamics 365 for Phones app must have the permission of Location in your mobile device.

Leave a Reply

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