FIlter Configuration in Contextual Search

adityavishnu
Giga Expert

Below is the code that i am using to filter the Knowledge Article based on Knowledge Base if the logged in user has a service_desk role, if not no filters.

 if (gs.hasRole('service_desk')) {

query_table.addQuery('kb_knowledge_base','d23ea8020f39df04c1931b2be1050e21');

}

query_table.addActiveQuery();

return query_table.getEncodedQuery();

This is working but even if the user does not have the role the if conditions is returning true.

Has anybody configured Filter Configurations? Any ideas what could go wrong?

6 REPLIES 6

Gurpreet07
Mega Sage

try to use GlideRecord sys_user_has_role table

 

var grRole =  new GlideRecord('sys_user_has_role');

grRole.addQuery('user',gs.getUserID());

grRole.addQuery('role.name','service_desk');

grRole.query();

if(grRole.hasNext()){

query_table.addQuery('kb_knowledge_base','d23ea8020f39df04c1931b2be1050e21');

}

query_table.addActiveQuery();

return query_table.getEncodedQuery();

Hey Thanks, the filter worked. Can you also suggest on sorting the result in filter config?

In the above code we are placing a filter on the Knowledge base but instead can we somehow sort the Search Result based on the Knowledge base.

For e.g. Knowledge Base Service Desk should show in the top.

In UI Element to Filter in Contextual Search, you mentioned about the sort option but the HI team said its not possible to sort using Knowledge Base by editing the Search Resource Property. INT3766934

My idea is to Glide Record the Knowledge table, sort it using KB and return the results from filter configuration. Do you have any other suggestions?

Hey we have a requirement that in response email there are kb links attached which comes based on description we want it only fromlegal kb articles not from all kb articles please help

Ayshee Chattopa
Giga Expert

Hi Gurprret,

I have a similar requirement where I need to display only the Knowledge Articles pertaining to the "Information Technology (Customer)" Knowledge Base as below :

find_real_file.png

However, this is not working.

Can you please help me understand where I am missing out?

Thank you,

Ayshee Chattopadhyay