- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2021 04:18 AM
Hi All,
As a part of one of the requirement, we wanted to remove "Popular Item" from the portal. I have tried the suggestions given on some of the community links but it doesn't seem to work
https://community.servicenow.com/community?id=community_question&sys_id=030a4b82db60db40fac7f4621f961986&view_source=searchResult
Also, instead of removing the widget itself, if someone helps me achieve how to show catalog item under the first category on sc category page instead of popular items. Categories are shown under Service Catalog change based on the user's location. So, I wanted to either display the item under the first category or completely remove the popular items
Any help would be appreciated.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2021 06:29 AM
Hello,
It sounds like you're wanting to remove these popular items, right?
These are built in to show up before any category is selected in the "SC Category Page" widget. To edit it you would have to clone the widget, then replace the old widget on the page with the newly cloned widget.
In the Server script, lines 42-49, is what controls what happens when there is no category selected:
if (GlideStringUtil.nil(data.category_id)) {
data.items = getPopularItems();
data.show_popular_item = true;
data.all_catalog_msg = (($sp.getCatalogs().value + "").split(",")).length > 1 ? gs.getMessage("All Catalogs") : "";
data.all_cat_msg = gs.getMessage("All Categories");
data.category = {title: gs.getMessage("Popular Items"),
description: ''};
return;
}
So you could change what occurs in that if to remove popular items.
If you want this to display completely blank instead, you could have it just return when there is no category_id:
if (GlideStringUtil.nil(data.category_id)) {
return;
}
Or, if you want to display a particular category instead, you could potentially add an instance option for the default category, have something like:
if (GlideStringUtil.nil(data.category_id)) {
if(!GlideStringUtil.nil(options.category_id)) {
data.category_id = options.YOUR-OPTION-NAME;
} else {
return;
}
}
Which would then load the category as though someone had selected it.
If it just returns there, you would see "No items in category" display, so you could add a condition in the HTML Template to line 23:
<div class="col-sm-6 col-md-4" ng-if="!data.items.length && !data.error && data.category_id">
${No items in category}
</div>
Indicating to only show that when there is a category_id.
Keep in mind if you're replacing the category with another category that whoever is viewing should have access to the category -- Otherwise it would display that they don't have permission to view it. It's also server-side code that's setting the category_id, so my idea had been to have an option to choose a default category, but you could do whatever logic you'd like to fetch a category
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2021 06:29 AM
Hello,
It sounds like you're wanting to remove these popular items, right?
These are built in to show up before any category is selected in the "SC Category Page" widget. To edit it you would have to clone the widget, then replace the old widget on the page with the newly cloned widget.
In the Server script, lines 42-49, is what controls what happens when there is no category selected:
if (GlideStringUtil.nil(data.category_id)) {
data.items = getPopularItems();
data.show_popular_item = true;
data.all_catalog_msg = (($sp.getCatalogs().value + "").split(",")).length > 1 ? gs.getMessage("All Catalogs") : "";
data.all_cat_msg = gs.getMessage("All Categories");
data.category = {title: gs.getMessage("Popular Items"),
description: ''};
return;
}
So you could change what occurs in that if to remove popular items.
If you want this to display completely blank instead, you could have it just return when there is no category_id:
if (GlideStringUtil.nil(data.category_id)) {
return;
}
Or, if you want to display a particular category instead, you could potentially add an instance option for the default category, have something like:
if (GlideStringUtil.nil(data.category_id)) {
if(!GlideStringUtil.nil(options.category_id)) {
data.category_id = options.YOUR-OPTION-NAME;
} else {
return;
}
}
Which would then load the category as though someone had selected it.
If it just returns there, you would see "No items in category" display, so you could add a condition in the HTML Template to line 23:
<div class="col-sm-6 col-md-4" ng-if="!data.items.length && !data.error && data.category_id">
${No items in category}
</div>
Indicating to only show that when there is a category_id.
Keep in mind if you're replacing the category with another category that whoever is viewing should have access to the category -- Otherwise it would display that they don't have permission to view it. It's also server-side code that's setting the category_id, so my idea had been to have an option to choose a default category, but you could do whatever logic you'd like to fetch a category
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2021 10:07 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2021 03:38 PM
Nishant,
I believe there is an OOB widget that would solve your requirements. Try using the Catalog Content widget instead of the Popular Items widget.
The Catalog Content widget is part of the Service Catalog and includes a tiled list of all the content items available in the catalog.
https://docs.servicenow.com/search?q=catalog+content+widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2021 10:42 PM
Hi Barbara,
Can you please help me out with the script for the requirement to show all items of all the catalogs available to the user instead of showing popular items?