Recent and Popular Item widget showing IT catalog items in ESC portal

Harshita Omer1
Tera Contributor

Hi All,

 

In my ESC portal > Recent and Popular Item section showing me the catalogs item from IT portal. Therefore I have cloned the widget and made the changes to show the catalog items from HR in My Recent Item, but I am not able to do the same for Popular Item section. 

The Popular Item is calling a separate script include (SCPopularItems) which is fetching the data to display from 'catalog_channel_analytics' table. Currently, it is displaying the data from HR Service Catalog as well as from IT Service Catalog. 

 

I have tried few ways to do it, but not able to achieve the required result. Can you please help here. 

Thanks in Advance! 

 

Widget > Server Script for Popular Item: 

data.popularItems = getPopularItems();
 
function getPopularItems() {
        return new SCPopularItems().useOptimisedQuery(gs.getProperty('glide.sc.portal.popular_items.optimize', true) + '' == 'true')
            .baseQuery(options.popular_items_created + '')
            .allowedItems($sp.getAllowedItems())
            .visibleStandalone(true)
            .visibleServicePortal(true)
            .itemsLimit(options.limit || 

 

.restrictedItemTypes(['sc_cat_item_guide', 'sc_cat_item_wizard', 'sc_cat_item_content', 'sc_cat_item_producer'])
            .itemValidator(function(item, itemDetails) {
                if (!item.canView(gs.isMobile()) || !item.isVisibleServicePortal())
                    return false;
 
                return true;
            })
            .responseObjectFormatter(function(item, itemType, itemCount) {
return {
order: 0 - itemCount,
name: item.name,
short_description: item.short_description,
picture: item.picture,
price: item.price,
sys_id: item.sys_id,
hasPrice: item.price != 0,
page: itemType == 'sc_cat_item_guide' ? 'sc_cat_item_guide' : 'sc_cat_item'
};
 
            })
            .generate();
    }
1 REPLY 1

Community Alums
Not applicable

Hello @Harshita Omer1 ,

 

Full understanding of the behavior of these two widgets: https://www.servicenow.com/community/hrsd-forum/how-does-quot-recommended-for-you-quot-and-quot-popu...

 

Thanks!