How to populate Catalog item based on user login?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 03:07 AM
Hi All,
I have requirement, to populate catalog item based on user login using back ground script.
Example: If Able Turte login to the portal he has only some catalog item has access to visible That item has visible using background script .Please help me on this .
Thanks
Suresh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 03:11 AM
You can define "user criteria" for those catalog items, it is an OOB functionality provided by ServiceNow to show/hide catalog items based on roles and conditions.
Please find this link for more info on user criteria, you can also mention conditional scripts in the User Criteria.
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 03:31 AM
Hi Prince,
In user criteria we have only 30 user criteria. If we not created user criteria for all catalog item . That's item has to visible for based on login user using background script.
Thanks,
Suresh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 03:15 AM
You can use UserCriteriaLoader API for this.
Example below:
var allCriterias = new sn_uc.UserCriteriaLoader.getAllUserCriteria(gs.getUserID());
gs.info(allCriterias);
gs.info(allCriterias.length);
Reference:
UserCriteriaLoader - API to Evaluate User Criteria
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 03:32 AM
Hi Ankur,
In user criteria we have only 30 user criteria. If we not created user criteria for all catalog item . That's item has to visible for based on login user using background script.
Thanks
Suresh