How to make service catalog item visible to only US users?

astanley
Tera Contributor

How to set the user criteria to us users only? I have a catalog item I want to be visible only to users in the US and there's no group containing all US users.

1 ACCEPTED SOLUTION

Hi Astanley,

Kindly update the script as below 

var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id','user_id');//country=US^active=true
userGR.query();
if (userGR.next()) {
if(userGR.location.country == 'US')
{
answer = true;
}
else{
answer = false;
}
}

Regards,

Deepankar Mathur

View solution in original post

6 REPLIES 6

dmathur09
Kilo Sage
Kilo Sage

Hi,

You would need to create user criteria and do a advanced condition. You can check for the user's location and then dot walk to the country of the user.

find_real_file.png

Regards,

Deepankar Mathur

Hello, I appreciate the assistance. Can you please share the script I can use. The country I am using is US.

I have used the following however, it is not visible to users with the country US.

var userGR = new GlideRecord('sys_user');
userGR.addEncodedQuery('country=US^active=true');//country=US^active=true
userGR.addQuery('sys_id',gs.getUserID());
userGR.query();
if (userGR.next()) {
answer = true;
} else {
answer = false;
}

Hi Astanley,

Kindly update the script as below 

var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id','user_id');//country=US^active=true
userGR.query();
if (userGR.next()) {
if(userGR.location.country == 'US')
{
answer = true;
}
else{
answer = false;
}
}

Regards,

Deepankar Mathur