Reference Country Code from a User profile in a script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 05:34 AM
We're trying to amend a script that was using the sys id of the domain to determine whether a user from different domains can see various things. This is current and works:
var Remote = Class.create();
Remote.prototype = {
initialize: function() {
},
domID: function() {
var userObj = gs.getUser().getDomainID();
if(userObj == "8715208d375c41728366542518276g52")
return true;
},
type: 'Remote'
};
But we want to amend this to look at the users' country code entry instead, so we've attempted a few options and this is what I thought it would be but its not working. The country code is showing on the user profile in the OOTB country field as a choice from a list
var Remotec = Class.create();
Remote.prototype = {
initialize: function() {
},
domID: function() {
var userObj = gs.getUser().getCountry();
if(userObj == "GB")
return true;
},
type: 'Remote'
};
Can anyone suggest what would be required to reference the country code field from the user profile?
Ive tried variations on getCountry like getcountry, sys_id.country etc, but nothing is working so far. Country field showing below

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2018 05:39 AM
HI,
After investigation i have one script for you:
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',gs.getUserID());
gr.query();
if(gr.next())
{
if(gr.country == 'GB' || gr.country == 'FR')
{
answer= true;
}
else{
answer= false;
}
}
else
{
answer= false;
}
Thanks,
Ashutosh Munot
Please Hit Correct, Helpful or like,if you are satisfied with this response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2018 12:51 AM
Hi,
Can you close this thread.
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2018 06:02 AM
For me this works Like a PRO.... Try this code and let me know.
Thanks,
Ashutosh