- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 12:41 PM
We would like to show all catalog items on load for the service catalog. Use case: Users just select something they see instead of searching for proper form which leads to misrouting.
I have tried changing the instance option number of items on page, but 12 are displayed no matter what I enter. I'd rather show all items instead of all popular, though.
From searching the community, lines 42-50 in the server script are what dictates what to display when there is no category.
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;
}
Is there a way to edit this so all items are shown? Possibly by popularity?
Thanks in advance for any suggestions!
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 11:53 AM
Line 165 in server script has an itemsLimit that was set to 6. Raising this number allows more items to display.
Lines 159-169:
function getPopularItems() {
return new SCPopularItems().useOptimisedQuery(gs.getProperty('glide.sc.portal.popular_items.optimize', true) + '' == 'true')
.baseQuery(options.popular_items_created + '')
.allowedItems(getAllowedCatalogItems())
.visibleStandalone(true)
.visibleServicePortal(true)
.itemsLimit(75)
.restrictedItemTypes('sc_cat_item_guide,sc_cat_item_wizard,sc_cat_item_content,sc_cat_item_producer'.split(','))
.itemValidator(function(item, itemDetails) {
if (!item.canView() || !item.isVisibleServicePortal())
return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 12:48 PM
Hello,
In the function getPopularItems() you can remove the limit 9
function getPopularItems() {
--code--
--code--
replace while (count.next() && items.length < 9) with while (count.next()).
One thing to keep in mind is that it is not advisable to remove the limit altogether as it will greatly affect the load time of your service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:35 PM
Thanks
line 43: data.items = getPopularItems();
line 177: while (count.next() && items.length < limit) {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:39 PM
what is the value of limit in line 177?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:41 PM
there is none...
168-193:
var count = new GlideAggregate('sc_req_item');
count.addAggregate('COUNT','cat_item');
count.groupBy('cat_item.sys_id');
count.addQuery('cat_item.sys_class_name', 'NOT IN', 'sc_cat_item_guide,sc_cat_item_wizard,sc_cat_item_content,sc_cat_item_producer');
count.addQuery('cat_item', "IN", allowedItems);
count.addQuery('cat_item.visible_standalone','true');
count.addEncodedQuery(createdQuery + 'cat_item.hide_sp=false^ORcat_item.hide_spISEMPTY');
count.orderByAggregate('COUNT', 'cat_item');
count.query();
while (count.next() && items.length < limit) {
var catalogItemJS = new sn_sc.CatItem(count.getValue("cat_item.sys_id"));
if (!catalogItemJS.canView() || !catalogItemJS.isVisibleServicePortal())
continue;
var item = {};
var catItemDetails = catalogItemJS.getItemSummary();
item.order = 0 - count.getAggregate('COUNT', 'cat_item');
item.name = catItemDetails.name;
item.short_description = catItemDetails.short_description;
item.picture = catItemDetails.picture;
item.price = catItemDetails.price;
item.sys_id = catItemDetails.sys_id;
item.hasPrice = item.price != 0;
item.page = 'sc_cat_item';
items.push(item);
}