Show all items of all the categories instead of Popular items
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2021 11:12 AM
How can i show all the items belonging to all catalogs and the categories available for a user in this Sc category widget instead of just showing the Popular items, How can i achieve this?
- Labels:
-
Request Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 09:08 AM
Hello,
I don't want to show popular item and i don't want to show Catalog.
I want to show Category--> "getAllowedCategoryItems()" from table "sc_category" but don't work. Do you have any idea?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2021 01:40 AM
Thanks Shivani, i am able to do it using below complete code, i am sharing this for others who may face this issue:
function getPopularItems() {
var items = [];
var allowedItems = getAllowedCatalogItems();
var count = new GlideRecord('sc_cat_item');
count.orderBy('name');
count.addQuery('sys_id', "IN", allowedItems);
count.addEncodedQuery('active=true');
count.query();
while (count.next()) {
var catalogItemJS = new sn_sc.CatItem(count.getValue('sys_id'));
if (!catalogItemJS.canView() || !catalogItemJS.isVisibleServicePortal())
continue;
var item = {};
var catItemDetails = catalogItemJS.getItemSummary();
item.name = catItemDetails.name;
item.short_description = catItemDetails.short_description;
item.sys_id = catItemDetails.sys_id;
item.page = 'sc_cat_item';
item.type = catItemDetails.type;
item.sys_class_name = catItemDetails.sys_class_name;
if (item.type == 'content_item') {
item.content_type = catItemDetails.content_type;
item.url = catItemDetails.url;
if (item.content_type == 'external') {
item.target = '_blank';
}
}
items.push(item);
}
return items;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 11:03 AM
This works great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2022 02:35 AM
Alternative approach without modifying OOTB "sc_category page" widget:
In the widget instance, change sc_category page to Catalog item page which will add "sp?id=catalog_items" to the instance URL and show up all items.