How to make Knowledge Facet Field widget to display only a specific KB categories instead of displaying all KBs categories?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2018 11:27 AM
I have a requirement to display categories of a specific KB. When a user does a seach in the portal, the categories of the specific KB should be displayed after the search results are returned.
For this, I'm using a widget called Knowledge Field facet. The issue is it displays the categories from all the knowledge bases while I'm trying to show the category for the specific KB it's being used on. Here's the server script:
(function($sp) {
if(!input){
//set instance sys_id to be used as unique id for collapse
options.table = "kb_knowledge";
data.instanceid = $sp.getDisplayValue('sys_id');
options.min_result_count = options.min_result_count ? parseInt(options.min_result_count) : 10;
options.min_scroll_count = options.min_scroll_count ? parseInt(options.min_scroll_count) : 10;
options.max_string_length = options.max_string_length ? parseInt(options.max_string_length) : 80;
options.aggregate_query = options.aggregate_query ? options.aggregate_query == 'true' : false;
options.show_empty_value = options.show_empty_value ? options.show_empty_value == 'true' : false;
options.alt_url_params = options.alt_url_params || "";
data.facet_depth = parseInt(gs.getProperty('glide.knowman.search.facet_depth') || 300);
var facet_type = 'single_select';
if(options.custom_template){
var tempAry = options.custom_template.toString().split(",");
options.custom_template = tempAry[0];
if(tempAry[1]){
facet_type = tempAry[1];
}
}else if(options.template){
if(options.template == 'kb_facet_multi_select'){
facet_type = 'multi_select';
}else if(options.template == 'kb_facet_dropdown_select'){
facet_type = 'dropdown_select';
}
}
options.facet_type = facet_type;
//get html template from options
options.template = options.custom_template ? options.custom_template : (options.template ? options.template : "kb_facet_single_select");
//get the template URL/path
data.template = options.template;//$sp.translateTemplate(options.template);
var kbService = new KBPortalService();
var valid_field = kbService.isValidFacetField(options.table,options.field_name,options.max_string_length);
//Verification for Invalid Fields
data.valid_field = valid_field;
data.is_admin = gs.hasRole("admin");
}else{
if(input){
var result = {};
var facetService = new KBPortalService();
result = facetService.getFacetByName(
input.name,
input.value,
input.keyword,
input.language,
input.variables,
input.query,
input.order
);
data.result = new global.JSON().decode(result+"");
}
}
})($sp);
I tried KBv3 and made it to only show categories from a specific KB as required, but the team doesn't like the search result display of KBv3 because when you search, the categories are gone in the returned search result while the requirement is to keep the categories after the search result.
Any help appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2019 04:27 AM
Hey Alex, were you able to implement this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2019 09:43 PM
This functionality is now available with New York. Use the 'Knowledge Bases" related tab.