How can I fetch catalog item's sys_id or name in User Criteria script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2020 03:48 AM
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
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2020 04:01 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2020 04:13 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2020 04:16 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2020 04:32 AM
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