VA- How to exclude all the catalog items associated with HR Services Catalog from Contextual search
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 01:26 AM
Need help to exclude all the catalog items associated with HR Services Catalog from Contextual search of a topic.
Currently it shows all the relevant catalog item options with image with any input keyword. It searches the keyword and gives the relevant items in virtual agent chat.
here is the script :
(function execute() {
var search_term = vaInputs.search_term.getValue();
//Filter out any catalog items that should not be shown ie. Record Producers
//create a filterMap to quickly see if item can be shown to user
var filter_tables = vaVars.filter_tables.split(',');
var filterMap = {};
for (var i=0; i < filter_tables.length; i++) {
filterMap[filter_tables[i]] = 'true';
}
var gr = sn_sc.CatalogSearch.search("", "", search_term, false, false, true);
gr.query();
var count = 0;
var results = [];
while (gr.next() && results.length < parseInt(vaVars.limit)) {
var catItemId = gr.getValue("sys_id");
var catItemObj = new sn_sc.CatItem(catItemId);
// Check if the catalog is HR Services and skip it if it is
// if (catItemObj.getCategory().getCatalog().sys_id == '7b0370019f22120047a2d126c42e7075') {
// continue;
// }
if (!catItemObj.canView())
continue;
var catItemJson = catItemObj.read({
"name" : "",
"sys_class_name" : ""
}, true);
if (filterMap[catItemJson.sys_class_name] == undefined) {
results.push({
'sys_id': catItemId,
'title': catItemJson.name,
'image': catItemObj.getIcon()
});
count++;
}
}
vaVars.count = results.length;
vaVars.results = JSON.stringify(results);
return '';
})()
I tried restricting the HR services catalog item by providing the sys id but it doesn't work.
Can you please help.
Regards,
Koyel
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 01:27 AM
Hi @Koyel Guha did you manage to solve this, am having exactly the same issue 🙂