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

Hello Ayshee / Anyone,

 

Did you happen to ever get this to work?  I have tried everything to try and get this RP Filter config to work, nothing below seems to work. 

Here are the log entries, it seem to be getting the proper values but the filter seems to never be applied.

*** KB Filter DEBUG ***
Filter=^cmdb_ci.company=1b22060f1bc93f80a4dc43f9cd4bcb4c
  • Tried using record producer Caller's Company to filter KBs based on Configuration item Company
(function buildFilter(producer) {
  var filter = "";

  if (producer.caller_id) {
    filter += "^cmdb_ci.company=" + producer.caller_id.company + "";
  }

  gs.log('*** KB Filter DEBUG ***\nFilter=' + filter);

  return filter;

})(producer);
  • Tried Adding a custom Company field on kb_knowledge table

 

(function buildFilter(producer) {
  var filter = "";

  if (producer.caller_id) {
    filter += "^u_company=" + producer.caller_id.company + "";
  }

  return filter;

})(producer);​
  • Tried adding company variable on record producer
(function buildFilter(producer) {
  var filter = "";

  if (producer.company) {
    filter += "^u_company=" + producer.company + "";
  }

  return filter;

})(producer);

 

Thanks in advance!

Hey i have smilar requirement that in response email we want links from legal kb article currently its searching for all kb articles can anyone help