How to restrict a catatog item to only for managers and team lead

avinashdubey103
Tera Guru

 I have a requirement to allow only managers and Tl to access and raise request 

1 ACCEPTED SOLUTION

@avinashdubey103 

try this

// check if logged in user has u_manager_type not as empty and value is not NON

var grSysUser = new GlideRecord('sys_user');
grSysUser.addQuery('sys_id', user_id);
grSysUser.addEncodedQuery("u_manager_typeISNOTEMPTY^u_manager_type!=NON");
grSysUser.query();
answer = grSysUser.hasNext();

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Sagar Pagar
Tera Patron

Hi @avinashdubey103,

 

You need to create User Criteria with conditions and apply it to Catalog item.

Apply user criteria to items and categories 

 

If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow

Ankur Bawiskar
Tera Patron
Tera Patron

@avinashdubey103 

you should use User Criteria.

Did you start the script for that?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

hi , started the script :but not able to understand  how set the user :

avinashdubey103_0-1702288154534.png

Code:
var grSysUser = new GlideRecord('sys_user');
grSysUser.addEncodedQuery("u_manager_typeISNOTEMPTY^u_manager_type!=NON");
grSysUser.query();
while (grSysUser.next()) {

}

@avinashdubey103 

try this

// check if logged in user has u_manager_type not as empty and value is not NON

var grSysUser = new GlideRecord('sys_user');
grSysUser.addQuery('sys_id', user_id);
grSysUser.addEncodedQuery("u_manager_typeISNOTEMPTY^u_manager_type!=NON");
grSysUser.query();
answer = grSysUser.hasNext();

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader