How to control Popular Items content

chrish5
Giga Guru

I’m seeing in other Community postings that you can control what shows up in the Service Portal "Popular Items" by cloning the SC Popular Items widget and adding script like I’ve done in the below screenshot.  This is not getting me the desired results and does appear to be removing any of the catalog items I need removed from Popular Items.   If I right-click/Ctrl on Popular Items in the Service Portal and select Instance in Page Editor, the widget it is using is SC Category Page.  So, should I actually be cloning the SC Category Page widget and adding my script to that?   If so, where?  I don’t see anywhere its Server Script that it is doing any count.AddQuery.   Thanks.

 

find_real_file.png

8 REPLIES 8

Sagar Pagar
Tera Patron

Hi,

 

Your query should be

count.addQuery('cat_item.category!=sys_id_of_category');

or

count.addEncoddedQuery('cat_item.categoryNOT LIKEIT ONLY');

 

Thanks!

Sagar Pagar

The world works with ServiceNow

Sulabh Garg
Mega Sage
Mega Sage

Hello Chrish,

Yes you need to clone the widget "SC category page". Below are the steps

1) find_real_file.png

 

2) On widget, you have to go to the function getPopularItems () on 156 line of the server code to change the query conditions. Please see below screenshots

 find_real_file.png

Hope it helps!!

 

Please Mark Correct/helpful, if applicable, Thanks!! 

Regards

Sulabh Garg

Please Mark Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg

Hi Sulabh,

Thank your for you reply.  My SC Category Page server script is not the same.  (full version attached)  These count.addQuery lines are what I saw and edited on the SC Popular Items widget server script.  

find_real_file.png

Hi Chrish,

Can you please check if your widget is customized by someone? Or It may be you are on san diego version and the code which I put in my screenshot above was from my PDI (Rome).

Hope it helps!!

Please Mark Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg