How to remove popular items

KS7
Kilo Contributor

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!

 

find_real_file.png

 

1 ACCEPTED SOLUTION

Barbara L - Gli
Tera Guru

Hello,

It sounds like you're wanting to remove these popular items, right?

find_real_file.png

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

View solution in original post

7 REPLIES 7

Barbara,

I need to show catalog items under the first category or a specific one on the SC Category Page instead of Popular Items.  I modified line 42-49 as you explained but I'm getting multiple error messages.  I used the Category sys id in line 44.

Can you please help me figure out what I've done wrong?

find_real_file.pngfind_real_file.png

Hi Barbara,

Were you able to find out the solution for this ?I m getting the same error.

Thanks

Thanks, @Barbara L - GlideFast 

It works for me too.

Ariel