How to create Tile view for catalog items with different catalogs- See my script and description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 06:48 AM - edited 10-19-2022 06:58 AM
I have created a new catalog in my instance. And also created a category and a catalog item under that catalog.
I want to create a tile view widget for catalog categories and catalog items with different catalogs and catagories.
In my code, Only categories under service catalog is visible. No other categories are visible.
check my code
(function() {
data.catalog_id = $sp.getParameter("sys_id") || $sp.getValue('sc_catalog');
if (!$sp.canReadRecord("sc_catalog", data.catalog_id)) {
data.error = "You do not have permission to see this catalog";
return;
}
if(data.category_id){
var currCat = new GlideRecord('sc_category')
if(currCat.get(data.category_id)){
data.category_title = currCat.title.toString();
}
}
var cat = new GlideRecord('sc_category');
cat.addQuery('sc_catalog',data.catalog_id);
cat.addEncodedQuery('title= Services^ORtitle=BSA^ORtitle=MarketingORtitle=Infra')
cat.orderBy('parent.title')
cat.orderBy('title');
cat.query();
var items = [];
var subItems = {};
while (cat.next()) {
// Does user have permission to see this category?
var catId = '' + cat.sys_id;
var catJS = new sn_sc.CatCategory(catId);
if (!catJS.canView()) {
continue;
}
var item = {};
$sp.getRecordDisplayValues(item, cat, 'title,description,homepage_image,sys_id');
item.sys_class_name = cat.sys_class_name + "";
if (!cat.parent || cat.parent == '') {
item.page = options.category_target_page;
subItems[cat.sys_id] = [];
items.push(item);
}
else {
item.page = options.subcategory_target_page;
var key = cat.parent.toString();
var array = subItems[key];
array.push(item);
subItems[key] = array;
}
}
data.subItems = subItems;
data.items = items;
})()
Using this code I can see three categories under service catalog in tile view.
cat.addEncodedQuery('title= Services^ORtitle=BSA^ORtitle=MarketingORtitle=Infra')
In the above line category named infra comes under Incident catalog(created by me). That is not visible in the tile view. How can i add that category too in the tile view.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 07:33 AM
Seems like ^ is missing, so try once by replacing
cat.addEncodedQuery('title= Services^ORtitle=BSA^ORtitle=MarketingORtitle=Infra')
with
cat.addEncodedQuery('title=Services^ORtitle=BSA^ORtitle=Marketing^ORtitle=Infra')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 07:53 AM
Tried. But not working.