Catalog Item - Who has Access

Florian Korbmac
Tera Contributor

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?

1 ACCEPTED SOLUTION

@Florian Korbmac 

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

UserCriteria - Scoped 

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.

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

View solution in original post

6 REPLIES 6

@Florian Korbmac 

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

Hi @Florian Korbmac 

 

What you are looking for is exactly not possible, you can check the Ankur code.

*************************************************************************************************************
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]

****************************************************************************************************************