Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to restrict catalog item for user country

prasadsnow
Tera Contributor

Hi Friends

I am working on some catalog item, and I have to restrict this catalog item based on user country,

I have tried using available with advance script like below, but its not working, 

Any idea, or any other way we can achieve this?

find_real_file.png

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi,

Try this instead:

checkCondition();

function checkCondition(){

var user = new GlideRecord('sys_user');
user.get(gs.getUserID());

if (user.location.country == "USA")
{
     return true;
}
     return false;
}

View solution in original post

7 REPLIES 7

I am sorry, its working Kieran, thanks 

Please try this one

var userGR = new GlideRecord('sys_user');
userGR.get('sys_id',user_id);

if (userGR.location.country == 'USA')
{
     return true;
}
     return false;
}

sachin_namjoshi
Kilo Patron
Kilo Patron

 

Use below code in your user criteria advanced script

 

checkCondition();

function checkCondition(){

var user = new GlideRecord('sys_user');
user.get(gs.getUserID());

if (user.location.country == "USA")
{
     answer=true;
}
     answer=false;
}

 

Regards,

Sachin