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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get the Logged in user location (country) in javascript code

(0) ShareShare
ReportReport
Posted on by 30

I have one requirement to implement which is, based on Logged In User's location (get country name) I have to set the currency in opportunity creation in D365, Please share your idea and thoughts how can it be achievable ?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: How to get the Logged in user location (country) in javascript code

    Hi Ankit,

    dynamics crm deosnt have any thing like this.

    you would require a very generic javascript. i.e using good API etc.

    Here few links i could find for you :  stackoverflow.com/.../find-user-location-using-jquery-js-without-google-geolocation-api  

    medium.com/.../how-to-detect-the-location-of-your-websites-visitor-using-javascript-92f9e91c095f

    tutorialzine.com/.../quick-tip-detecting-your-location-with-javascript

  • Suggested answer
    BadrinathB Profile Picture
    970 on at
    RE: How to get the Logged in user location (country) in javascript code

    Hi,

    If you want to get location using mobile devices then you can have a look here for some ideas.

    www.inogic.com/.../get-current-location-from-the-device-in-dynamics-365

    There are some web Apis available to track the geo location information. You need to consume them as per your requirements. You can even use IP lookups API to track the country.

    developer.mozilla.org/.../Geolocation_API

    medium.com/.../how-to-detect-the-location-of-your-websites-visitor-using-javascript-92f9e91c095f

  • Ankit S Profile Picture
    30 on at
    RE: How to get the Logged in user location (country) in javascript code

    Thanks for Reply, here my query is different, I can get the user setting's territoryid using webapi query in javascript. but I want logged-in user's machine's location (country) based on that I want to set currency while creating Opportunity.

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: How to get the Logged in user location (country) in javascript code

    Hi Ankit,

    You have to use wep api request to achieve this. create the JS and call the function on onload of the form or any other event.

    here is how you get the logged in user id =

    var userSettings = Xrm.Utility.getGlobalContext().userSettings; // userSettings is an object with user information. var current_User_Id = userSettings.userId; // The user's unique id var newid = current_User_Id.slice(1, -1);

    Then use rest builder to generate a request to get above user's location:
    https://github.com/jlattimer/CRMRESTBuilder/releases - download and install this tool
    - it will help to generate web api requests.


    0358.2.png


    0358.2.png

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans