Get logged in User's country
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2019 03:15 AM
Hi,
I am able to get the location of logged in User but I am not able to get the country. Please help.
gs.getUser().getLocation(); is working
gs.getUser().getLocation().country; is not working
Regards,
Sreedhar
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2019 03:47 AM
Hi All,
Thanks for your reply.
I am trying to find a way to implement this without using a script include. Please let me know if there is an OOB function that could help me achieve this.
Regards,
Sreedhar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2019 03:52 AM
Hi
You can try the script suggested above by me in your script include.
Regards,
Omkar Mone.
www.dxsherpa.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2019 03:54 AM
You cannot get the country value directly. in that case you need to have country field in the user table. Then you can retrieve it.you cannot dot walk inside a reference field
https://www.servicenowguru.com/scripting/user-object-cheat-sheet/
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2020 05:27 AM
javascript:GlideLocale.get().getCurrent().getCountry()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2020 08:12 AM
Hi
Here is an updated Script:
var user = new GlideRecord("sys_user");
user.addQuery("sys_id", gs.getUserID());
user.setLimit(1)
user.query();
if (user.next()) {
gs.info(user.name);
gs.info(user.getDisplayValue("location"));
gs.info(user.location.country);
}
If the script returns an empty result, your "Location" record does not have any "Country" value set.
BR
Dirk