Follow my blog for interesting topics on Dynamics 365, Portals and Power Platform.
The world is into mobile devices and Dynamics 365 is not left far behind. With unified interface, user’s are now getting seamless experience across all devices starting from web browser in desktop clients, to phones and tablets.
Dynamics 365 is well and try mobile now.
And when you are in mobile platform, you may feel the need to know device location. And believe me, Microsoft have provided you an API which can give you just that. Following is the code to do that.
Xrm.Device.getCurrentPosition().then(
function success(location) {
console.log("Latitude", ":", location.coords.latitude);
console.log("Longitude:", location.coords.longitude);
},
function (error) {
console.log("error in determining location :", error.message);
}
);
Please note that the above code will only run on mobile platforms (tablets & Phones). Trying to run it on Web browser in desktop will give you an error – “Operation is not supported by platform.”
Hope this helps!
Debajit Dutta
(Microsoft MVP)
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.