How can I fetch catalog item's sys_id or name in User Criteria script?

Akshat Joshi
Kilo Contributor

Hey Folks!

I want to apply a scripted User Criteria to some of the catalog items. To determine the visibility, I need the name of the catalog item(or sys_id) of the catalog item.

I have already tried using RP.getParameterValue("sysparm_id") mentioned in this link https://community.servicenow.com/community?id=community_question&sys_id=1546cba1db1cdbc01dcaf3231f9619fe. However, it gives an error saying RP is not defined. Could you please suggest an alternative to this?

Thanks,

Akshat

13 REPLIES 13

Anil Shewale
Mega Guru

hi 

you can use g_form and g_form.getUniqueValue()  it will give you the current sys_id.

example:

var Sysid = g_form.getUniqueValue();

 

If it help mark helpful or correct 

Thanks and regards

Anil

Hi Anil,

 

I do not think this will work. User Criteria scripts run on the Server side, g_form will not be accessible there.

 

Thanks,

Akshat

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Akshat,

why you want to use hard-coded sys_id of catalog item; If the user satisfies the criteria the catalog item would be shown

Regards
Ankur

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

Hi Ankur,

 

To determine whether the user satisfies the User Criteria, I need to query the name of the catalog item to another table and then evaluate whether the user should have access to the catalog item.

 

Thanks,

Akshat