Inactive knowledge categories are still displaying as search source filters

LizB
Tera Expert

We have recently inactivated a knowledge base and additionally inactivated its corresponding knowledge categories.  However our search page which uses a custom search source is still displaying the inactive categories.  It looks as if the following call is getting the list of knowledge categories:

 

KBPortalServiceImpl().getAllFacets(query, '',
'{"kb_knowledge_base":{"aggregate":false,"include_null":false,"orderby":"label","table":"kb_knowledge","value":[]},
"author":{"aggregate":false,"include_null":false,"orderby":"label","table":"kb_knowledge","value":[]},
"kb_category":{"aggregate":false,"include_null":true,"orderby":"label","table":"kb_knowledge","value":[]}}',

......

......

 

Is there anything that I can add to this line of code to tell the getAllFacets method to only return active categories?

"kb_category":{"aggregate":false,"include_null":true,"orderby":"label","table":"kb_knowledge","value":[]}}',

 

Thanks

 

Liz B

2 REPLIES 2

Ratnakar7
Mega Sage
Mega Sage

Hi @LizB ,

 

Here's how you can achieve this:

Modify your GlideAggregate query to include a condition that filters out inactive categories. You can use the active field to check if the category is active or not. Here's an example of how you can do this:

var kbCategories = new GlideAggregate('kb_category');
kbCategories.addQuery('active', true); // Add this line to filter out inactive categories
kbCategories.query();
kbCategories.addAggregate('COUNT');
kbCategories.groupBy('label');

Save your changes and test your search source. Now, it should only include active knowledge categories.

 

Thanks,

Ratnakar

Yes I know that I can create a query to filter out the inactive categories, using a Glide class, but the search source is using the following method to get the categories so my question is how to use this call to filter the inactivate categories:

 

Is there anything that I can add to this line of code to tell the getAllFacets method to only return active categories?

"kb_category":{"aggregate":false,"include_null":true,"orderby":"label","table":"kb_knowledge","value":[]}}',