Making a Service Catalog "Available For"

rafaelcosta
Kilo Contributor

Hello.   I have to set up a catalog of services so that it is visible only to Brazil's users.

I am using the following script:  

var g = new GlideRecord ( ' sys_user ');

gr.addQuery ( 'country ', ' BR ');

gr.addActiveQuery ();

gr.query ();

gr.next ();  

And it's not working. This script was written within the tab " Available for " catalog,  

Can you help me please?

4 REPLIES 4

Harsh Vardhan
Giga Patron

Hi Rafel,



this way you can also restrict the visibility of your catalog.


Please refer the link below.



Legacy:Service Catalog Access Controls - ServiceNow Wiki



User Criteria - ServiceNow Wiki



Regards,


Harshvardhan


vaibhavshinde
Kilo Expert

Hey,



Have tried using the User Criteria. It is more simpler than writing a script.



Just create a user criteria, add a country Brazil.



On the catalog item or category, add this User Criteria under the 'Available for' section



Regards,


VS


Daniel Slocum
ServiceNow Employee
ServiceNow Employee

Good day Rafael,



A simpler method would be to list the Brazilian locations in the location Glide list on the User Criteria form.   The way you are trying to code this, only users at the top level of Brazil would have access to the Catalog. Locations should be found on the same form you are using to enter the code.


Mihir Mohanta
Kilo Sage

Use the below script in the user criteria you have created for this.



checkAvailability();


function checkAvailability(){


var gr = new GlideRecord ('sys_user');


gr.get(gs.getUserID());


if (gr.country == 'BR') {


      return true;


} else {


      return false;


}


}




Thanks,


Mihir