- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2020 12:42 PM
Is it possible to hide a popular item from popping up here? So if I don't want apple ipad 3 to not show up in the popular item is it possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2020 02:55 PM
Best Practice would be to create a system property and store comma separated sys_id values of the to be hidden catalog items in this property.
Then you can add below one line of the code in Server Script of cloned widget. That is it. You are set.
Next time when you are asked to again exclude/include another catalog item , You just need to add sys_id of the catalog items in the property. No code change required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2020 06:24 PM
Allen,
yea I am learning alot of stuff.
Thanks,
John

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2020 06:41 PM
🙂 Awesome!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2020 05:07 AM
Hi John,
Can't figure out if you fixed this already, though if not.
- Clone the widget
- Have a look at the Server Script, and function "getAllowedCatalogItems"
--- Several ways to go with this function, though quickest cheat would be changing:
if (allowedItems.indexOf(catItemIds[i]) < 0)
Into:
if (allowedItems.indexOf(catItemIds[i]) < 0 && catItemIds[i] != 'the_apple_ipad3_sysid')
I do call this a quick cheat 🙂
It will work fine, though it would be nicer to think of a more maintainable way. For example storing the Items you want to hide somewhere, in a system property/table etc, and read that in this script.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2020 05:17 AM
Mark,
No I haven't figure it out yet. So once I clone the widget and add the code, make it public is there anything else I need to do after that?
Thanks,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2020 05:25 AM
I don't see that line of code in mine.
function getAllowedCatalogItems () {
var allowedItems = [];
catalogIDArr.forEach(function(catalogID) {
var catalogObj = new sn_sc.Catalog(catalogID);
var catItemIds = catalogObj.getCatalogItemIds();
for(var i=0; i<catItemIds.length; i++) {
if (!allowedItems.includes(catItemIds[i]))
allowedItems.push(catItemIds[i]);