- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 06:29 AM
We need a report that shows which user has access to a catalog item. Is there a way to implement this?
We only control access via user criteria and not via the service offerings.
But I can't find a way to see which users fulfill the user criteria and others may not.
Is there maybe an alternative?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2025 05:05 AM - edited ‎03-31-2025 05:11 AM
You won't know that in database view because user criteria is evaluated against catalog item in run-time.
But why you want the list of users for each catalog item. The number of catalog items would be huge and sys_user will also be huge. your report will be heavy.
what you can do is this to achieve your requirement
1) create a custom table which holds Catalog item (List field) and the Users (reference field) which has access to that catalog item
2) populate this table by leveraging the User Criteria API and use fix script.
3) then report on that custom table and then you know which catalog item has which users
Script, something like this, but please enhance
Note: your script will take long time as it will iterate each record of the table "sc_cat_item_user_criteria_mtom" and for all user records
// query sc_cat_item_user_criteria_mtom table and pick the criteria sysId and the catalog item
var gr = new GlideRecord("sc_cat_item_user_criteria_mtom");
gr.query();
while (gr.next()) {
var userSatisfying = [];
var itemArr = [];
var criteriaSysId = gr.getValue('user_criteria');
var userRec = new GlideRecord("sys_user");
userRec.addActiveQuery();
guserRecr.query();
while (userRec.next()) {
var userMatches = sn_uc.UserCriteriaLoader.userMatches(userRec.getUniqueValue(), criteriaSysId);
if (userMatches)
itemArr.push(gr.getValue('sc_cat_item'));
}
// now you get all users satisfying this catalog item, insert record into that table
}
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-28-2025 06:33 AM
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2025 04:02 AM
Hi @Dr Atul G- LNG,
thanks for the quick response.
That's not quite what I wanted. It would be best if I could get a list of users who can see the item for each catalogue item.
Here I ‘only’ get the user criteria. But that would also be fine. I just don't get the data displayed nicely.
I get them displayed as follows:
Catalog Item | Available for | Not available for |
Item 1 | User Criteria 1 | User Criteria 3 |
Item 1 | User Criteria 1 | User Criteria 4 |
Item 1 | User Criteria 2 | User Criteria 3 |
Item 1 | User Criteria 2 | User Criteria 4 |
But I can't build a decent report from this!
I have configured the database view as follows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2025 05:05 AM - edited ‎03-31-2025 05:11 AM
You won't know that in database view because user criteria is evaluated against catalog item in run-time.
But why you want the list of users for each catalog item. The number of catalog items would be huge and sys_user will also be huge. your report will be heavy.
what you can do is this to achieve your requirement
1) create a custom table which holds Catalog item (List field) and the Users (reference field) which has access to that catalog item
2) populate this table by leveraging the User Criteria API and use fix script.
3) then report on that custom table and then you know which catalog item has which users
Script, something like this, but please enhance
Note: your script will take long time as it will iterate each record of the table "sc_cat_item_user_criteria_mtom" and for all user records
// query sc_cat_item_user_criteria_mtom table and pick the criteria sysId and the catalog item
var gr = new GlideRecord("sc_cat_item_user_criteria_mtom");
gr.query();
while (gr.next()) {
var userSatisfying = [];
var itemArr = [];
var criteriaSysId = gr.getValue('user_criteria');
var userRec = new GlideRecord("sys_user");
userRec.addActiveQuery();
guserRecr.query();
while (userRec.next()) {
var userMatches = sn_uc.UserCriteriaLoader.userMatches(userRec.getUniqueValue(), criteriaSysId);
if (userMatches)
itemArr.push(gr.getValue('sc_cat_item'));
}
// now you get all users satisfying this catalog item, insert record into that table
}
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
‎04-01-2025 01:22 AM
Thank you for marking my response as helpful.
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