- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2023 03:51 AM
Is there a way to exclude a particular catalog item from showing up on the recommended for you widget in the employee centre portal ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 05:59 AM - edited 09-22-2023 06:01 AM
The code pasted below should ideally serve the purpose of just removing the catalog item from appearing on the portal.
Note: sn_hr_sp.ignoredCatalogs is a system property created that stores comma separated sys_ids of all those catalog items that are to be omitted from appearing on the portal.
(function() {
if (input && input.action == "loadData") {
var maxDisplayCount = 10;
data.instanceId = $sp.getDisplayValue("sys_id");
data.title = gs.getMessage(options.title);
data.userPredictionCount = options.user_prediction_count;
data.cardType = (options.list_type === 'Card List') ? options.card_behaviour + '' : '';
data.listType = (options.list_type === 'Card List') ? 'card-list' : 'simple-link';
var knowledgeBases = String($sp.getKnowledgeBases());
var displayCount = options.limit > maxDisplayCount ? maxDisplayCount : options.limit;
data.viewType = (displayCount > 3) ? 'max-view' : 'min-view';
var recentActivityCutoffInDays = options.recent_activity_cut_off_in_days;
var recentActivityCutoffDate = new GlideDateTime();
recentActivityCutoffDate.addDaysLocalTime(-recentActivityCutoffInDays);
var RelevantForYouUtil = new sn_hr_sp.RelevantForYouUtil();
var taxonomyId = $sp.getTaxonomies();
var catalogPayload = {
users: null,
catalogCount: displayCount,
ignoredCatalogs: 'Other Request',
recentActivityCutoffDate: recentActivityCutoffDate,
taxonomyId: taxonomyId
};
var articlesPayload = {
users: null,
knowledgeBases: knowledgeBases,
kbRecords : $sp.getAllKBRecords(knowledgeBases),
articleCount: displayCount,
recentActivityCutoffDate: recentActivityCutoffDate,
taxonomyId: taxonomyId
};
if (options.category === 'knowledge')
data.dataItems = RelevantForYouUtil.getRelevantArticlesAndCatalogs(articlesPayload, null, displayCount, data.userPredictionCount, taxonomyId);
else if (options.category === 'catalog')
data.dataItems = RelevantForYouUtil.getRelevantArticlesAndCatalogs(null, catalogPayload, displayCount, data.userPredictionCount, taxonomyId);
else
data.dataItems = RelevantForYouUtil.getRelevantArticlesAndCatalogs(articlesPayload, catalogPayload, displayCount, data.userPredictionCount, taxonomyId);
for(var i=0; i<data.dataItems.length;i++) {
var catIgnore = gs.getProperty('sn_hr_sp.ignoredCatalogs').split(',');
for (var j=0; j<catIgnore.length; j++)
{
if(data.dataItems[i].sys_id == catIgnore[j] ) {
data.dataItems.splice(i,1);
}
}
}
data.widgetsData = getWidgetsData(data.dataItems, data.listType);
}
function getWidgetsData(dataResults, listType) {
listType = (listType === 'card-list') ? 'card' : 'simple_link';
var dataPayload = [];
dataResults.forEach(function(article) {
var itemPayload = {};
var widgetName = article.category == 'catalog' ? 'catalog-content' : 'kb-content';
itemPayload.widgetTitle = data.title;
itemPayload.content = article.sys_id;
itemPayload.content_table = article.category == 'catalog' ? 'sc_cat_item' : 'kb_knowledge';
itemPayload.listType = listType;
itemPayload.widgetData = $sp.getWidget(widgetName, itemPayload);
dataPayload.push(itemPayload.widgetData);
});
return dataPayload;
}
})();
Please Mark the answer as helpful if it works 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2023 03:53 AM
HI @Shreyas Khade ,
I trust you are doing great.
Here's a step-by-step guide:
- Identify the catalog item you want to exclude. Note down its sys_id.
- Go to the Employee Centre portal and navigate to "Catalog" > "Catalog Items".
- Open the catalog item you wish to exclude.
- Under the "Order Guide" related list, click on the "View" link next to the order guide that includes the catalog item.
- Locate the "Client Script" related list and click on "New".
- In the new client script record, set the "Type" field to "onLoad".
- Add the following code to the script box:
function onLoad() {
g_form.setVisible('sc_order', false);
}
This code will hide the catalog item on the order guide form.
- Save the client script record.
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2023 04:02 AM
Hello @Amit Gujarathi , Hope you are doing well
The catalog item just needs to be kept hidden from appearing in the recommended for you widget but should be visible when searched.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 05:59 AM - edited 09-22-2023 06:01 AM
The code pasted below should ideally serve the purpose of just removing the catalog item from appearing on the portal.
Note: sn_hr_sp.ignoredCatalogs is a system property created that stores comma separated sys_ids of all those catalog items that are to be omitted from appearing on the portal.
(function() {
if (input && input.action == "loadData") {
var maxDisplayCount = 10;
data.instanceId = $sp.getDisplayValue("sys_id");
data.title = gs.getMessage(options.title);
data.userPredictionCount = options.user_prediction_count;
data.cardType = (options.list_type === 'Card List') ? options.card_behaviour + '' : '';
data.listType = (options.list_type === 'Card List') ? 'card-list' : 'simple-link';
var knowledgeBases = String($sp.getKnowledgeBases());
var displayCount = options.limit > maxDisplayCount ? maxDisplayCount : options.limit;
data.viewType = (displayCount > 3) ? 'max-view' : 'min-view';
var recentActivityCutoffInDays = options.recent_activity_cut_off_in_days;
var recentActivityCutoffDate = new GlideDateTime();
recentActivityCutoffDate.addDaysLocalTime(-recentActivityCutoffInDays);
var RelevantForYouUtil = new sn_hr_sp.RelevantForYouUtil();
var taxonomyId = $sp.getTaxonomies();
var catalogPayload = {
users: null,
catalogCount: displayCount,
ignoredCatalogs: 'Other Request',
recentActivityCutoffDate: recentActivityCutoffDate,
taxonomyId: taxonomyId
};
var articlesPayload = {
users: null,
knowledgeBases: knowledgeBases,
kbRecords : $sp.getAllKBRecords(knowledgeBases),
articleCount: displayCount,
recentActivityCutoffDate: recentActivityCutoffDate,
taxonomyId: taxonomyId
};
if (options.category === 'knowledge')
data.dataItems = RelevantForYouUtil.getRelevantArticlesAndCatalogs(articlesPayload, null, displayCount, data.userPredictionCount, taxonomyId);
else if (options.category === 'catalog')
data.dataItems = RelevantForYouUtil.getRelevantArticlesAndCatalogs(null, catalogPayload, displayCount, data.userPredictionCount, taxonomyId);
else
data.dataItems = RelevantForYouUtil.getRelevantArticlesAndCatalogs(articlesPayload, catalogPayload, displayCount, data.userPredictionCount, taxonomyId);
for(var i=0; i<data.dataItems.length;i++) {
var catIgnore = gs.getProperty('sn_hr_sp.ignoredCatalogs').split(',');
for (var j=0; j<catIgnore.length; j++)
{
if(data.dataItems[i].sys_id == catIgnore[j] ) {
data.dataItems.splice(i,1);
}
}
}
data.widgetsData = getWidgetsData(data.dataItems, data.listType);
}
function getWidgetsData(dataResults, listType) {
listType = (listType === 'card-list') ? 'card' : 'simple_link';
var dataPayload = [];
dataResults.forEach(function(article) {
var itemPayload = {};
var widgetName = article.category == 'catalog' ? 'catalog-content' : 'kb-content';
itemPayload.widgetTitle = data.title;
itemPayload.content = article.sys_id;
itemPayload.content_table = article.category == 'catalog' ? 'sc_cat_item' : 'kb_knowledge';
itemPayload.listType = listType;
itemPayload.widgetData = $sp.getWidget(widgetName, itemPayload);
dataPayload.push(itemPayload.widgetData);
});
return dataPayload;
}
})();
Please Mark the answer as helpful if it works 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 10:19 AM
NOTE - EXCLUDE ANY CATALOG ITEM USING BOOLEAN / CHECKBOX AS PER USER CHOICE
Used the above code but slightly different by using the check box (named - EXCLUDE) which is created