- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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.
Could anyone please guide me to achieve this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Logic I shared should work fine, provided you are using correct table and fields to query and grab the value
var catItemSysId = '6117697c1b803a1096064152b24bcba2'; // give sysId of your catalog item
var offeringArr = [];
var gr = new GlideRecord("service_subscribe_sys_user");
gr.addQuery("sys_user", user_id);
gr.query();
while (gr.next()) {
offeringArr.push(gr.getValue('service_offering'));
}
gs.info('Offering arr is' + offeringArr.toString());
var rec = new GlideRecord('sc_cat_item_subscribe_mtom');
rec.addQuery('sc_cat_item', catItemSysId);
rec.addQuery('service_offering', 'IN', offeringArr.toString());
rec.query();
if (rec.hasNext()) {
answer = true;
} else {
answer = false;
}
Try running this in background script and pass user sysId
var catItemSysId = '6117697c1b803a1096064152b24bcba2'; // give sysId of your catalog item
var offeringArr = [];
var gr = new GlideRecord("service_subscribe_sys_user");
gr.addQuery("sys_user", 'hardCodeSysId');
gr.query();
while (gr.next()) {
offeringArr.push(gr.getValue('service_offering'));
}
gs.info('Offering arr is' + offeringArr.toString());
var rec = new GlideRecord('sc_cat_item_subscribe_mtom');
rec.addQuery('sc_cat_item', catItemSysId);
rec.addQuery('service_offering', 'IN', offeringArr.toString());
rec.query();
gs.info('row count' + rec.getRowCount() + ' encoded query is' + rec.getEncodedQuery());
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
3 weeks ago
Logic I shared should work fine, provided you are using correct table and fields to query and grab the value
var catItemSysId = '6117697c1b803a1096064152b24bcba2'; // give sysId of your catalog item
var offeringArr = [];
var gr = new GlideRecord("service_subscribe_sys_user");
gr.addQuery("sys_user", user_id);
gr.query();
while (gr.next()) {
offeringArr.push(gr.getValue('service_offering'));
}
gs.info('Offering arr is' + offeringArr.toString());
var rec = new GlideRecord('sc_cat_item_subscribe_mtom');
rec.addQuery('sc_cat_item', catItemSysId);
rec.addQuery('service_offering', 'IN', offeringArr.toString());
rec.query();
if (rec.hasNext()) {
answer = true;
} else {
answer = false;
}
Try running this in background script and pass user sysId
var catItemSysId = '6117697c1b803a1096064152b24bcba2'; // give sysId of your catalog item
var offeringArr = [];
var gr = new GlideRecord("service_subscribe_sys_user");
gr.addQuery("sys_user", 'hardCodeSysId');
gr.query();
while (gr.next()) {
offeringArr.push(gr.getValue('service_offering'));
}
gs.info('Offering arr is' + offeringArr.toString());
var rec = new GlideRecord('sc_cat_item_subscribe_mtom');
rec.addQuery('sc_cat_item', catItemSysId);
rec.addQuery('service_offering', 'IN', offeringArr.toString());
rec.query();
gs.info('row count' + rec.getRowCount() + ' encoded query is' + rec.getEncodedQuery());
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
3 weeks ago
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
1. Have you checked
- Create catalog items for service offering subscribers in Service Portfolio Management
- Service offering to catalog item relationships
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 🙂