Catalog Item Restriction

leviii
Tera Contributor

Hello, 

 

Can someone know how to restrict catalog item visibility? catalog item must be only visible specifically for users with authorization level 3 and above.  I already created a user criteria and attached it in my catalog item but it is still not working.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@leviii 

please share your user criteria and script

Ensure you add that in "Available For" Related list of your catalog item

Script something like this, but please enhance

var userRec = new GlideRecord('sys_user');
userRec.addQuery('sys_id', user_id);
userRec.addQuery('u_authorization_leve', '3'); // give your proper query here
userRec.query();
answer = userRec.hasNext();

You can also test this using User Criteria Diagnostics

Debug user criteria of a catalog item 

If my response helped please mark it correct and close the thread so that it benefits future readers.

View solution in original post

5 REPLIES 5

Voona Rohila
Tera Patron

HI @leviii 

Please share the User criteria you configured?

 

Click on Advanced and refer below sample logic (change the field name and value acordingly)

var grSysUser = new GlideRecord('sys_user');
if (grSysUser.get(user_id)) {
    if (grSysUser.u_level == '3') //change the field name and value acordingly
        answer = true;
}

 

 

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
5x ServiceNow MVP

Ankur Bawiskar
Tera Patron

@leviii 

please share your user criteria and script

Ensure you add that in "Available For" Related list of your catalog item

Script something like this, but please enhance

var userRec = new GlideRecord('sys_user');
userRec.addQuery('sys_id', user_id);
userRec.addQuery('u_authorization_leve', '3'); // give your proper query here
userRec.query();
answer = userRec.hasNext();

You can also test this using User Criteria Diagnostics

Debug user criteria of a catalog item 

If my response helped please mark it correct and close the thread so that it benefits future readers.

@leviii 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.