I want to manage the visibility of catalog items only to the subscribers to the Service Offerings

pdurgapavan
Tera Contributor

I would like to show the catalog items to the users who subscribed to the Service Offerings. Let's say On the service_offering table, there is a service offering called "SAP Retail " and Abel was added to the Subscribed by user related list and there is a catalog item called "SAP Access for new hires " added under "Items orderable by subscribers" related list then users whoever subscribed can able to see the catalog item rest of all the users cannot able to see the catalog item.

 

pdurgapavan_0-1757947894276.png

pdurgapavan_1-1757947911303.png

Could anyone please guide me to achieve this.

 

@Dr Atul G- LNG 

@Ankur Bawiskar 

 

4 REPLIES 4

RaghavSh
Kilo Patron

Did you tried creating user criteria for your catalog item?

This will have to be dine through user criteria, create a user criteria and attach it to your catalog item under "available for".

 

For details refer: https://www.servicenow.com/community/developer-forum/user-criteria-on-catalog-item/m-p/2834070  You can write the script based on your tables


Raghav
MVP 2023

Ankur Bawiskar
Tera Patron
Tera Patron

@pdurgapavan 

you can use User Criteria and use advanced script and add it to "Available For" related list under your catalog item.

You will have to create separate user criteria for all your catalog items and hard-code the catalog item sysId

Something like this

Note: I believe you can add correct table name and respective table fields in below script and you can enhance it further. Also you cannot get the catalog item sysId dynamically and it has to be static always

var catItemSysId = 'sysId'; // give sysId of your catalog item

var offeringArr = [];

var gr = new GlideRecord("subscribedByUserTable");
gr.addQuery("userField", user_id);
gr.query();
while (gr.next()) {
    offeringArr.push(gr.getValue('offeringField'));
}

var rec = new GlideRecord('itemsOrderableBySubscriberTable');
rec.addQuery('catItemField', catItemSysId);
rec.addQuery('offeringField', 'IN', offeringArr.toString());
rec.setLimit(1);
rec.query();
answer = rec.hasNext();

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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @pdurgapavan 

The visibility of a catalog item can be handled through user criteria. Please create the appropriate user criteria and then check if it works as expected.

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

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

dzmitryKon
Tera Contributor

1. Have you checked 

Its a mature/service oriented way to manage catalogue; however may require some limitation in terms of 1-many ; many-to-many relationship; (if not mistaken it was impossible to link 1 Item to multiple offerings (check :)))

Alternatively you can build some Scripted User criteria to check dynamically link between users - related offerings - Related items and you may need to add some custom m2m tables in between

Thanks;
Please mark Solved/Helpful if Solved/was Helpful 🙂