Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Customise Knowledge Search

amacqueen
Mega Guru

We like many others, I'm sure, have the ability to search the knowledge base from Incident. I was wondering if there was a way to restrict the results displayed based on business service. I have already added business service to the knowledge base form and I was hoping there would be a way using the dictionary entry attributes of the description field which we use as the basis for searching the knowledge base, we currently have this set to:-

 

no_truncate=true,knowledge_search=true,ts_weight=10

 

Our business service field name is u_business_service.

 

TIA

1 ACCEPTED SOLUTION

solutioningnow
Giga Guru

Hi,



I have successfully configured the solution in one of the demo instance. For achieving you need to update below things:



Update dictionary attributes - knowledge_custom=customKnowledgeSearch,knowledge_search=false



Add onLoad Client Script:



function onLoad() {


  return;


}




function customKnowledgeSearch() {


  var searchText = g_form.getValue('short_description');


  var elementName = 'u_business_service';


  var url = 'kb_find.do?sysparm_search=' + escape(searchText);


  url += "&sysparm_nameofstack=kbpop";


  url += "&sysparm_kb_search_table=incident"; //This example runs on the Incident table. Edit the table name as necessary


  url += "&sysparm_operator=IR_AND_OR_QUERY"; //Tries an 'AND' exact match query and uses an 'OR' query if no exact match


  //url += "&sysparm_operator=IR_OR_QUERY"; //Searches using an 'OR' query


  //url += "&sysparm_operator=IR_AND_QUERY"; //Searches using an 'AND' query


  popupOpenStandard(url, "kb2task");


}



Please try and let me know the outcome



Regards,


Solutioner


View solution in original post

9 REPLIES 9

solutioningnow
Giga Guru

Hi Angus,



I have found similar solution in wiki, below is wiki url:



Administering Knowledge Search - ServiceNow Wiki



I am also trying to setup the same in some demo instance



Regards,


Solutioner


Hi,


I need to restrict Knowledge_search attribute. When i click, it should work only for "Finance Knowledge" base. Can anyone help on this.


solutioningnow
Giga Guru

Hi,



I have successfully configured the solution in one of the demo instance. For achieving you need to update below things:



Update dictionary attributes - knowledge_custom=customKnowledgeSearch,knowledge_search=false



Add onLoad Client Script:



function onLoad() {


  return;


}




function customKnowledgeSearch() {


  var searchText = g_form.getValue('short_description');


  var elementName = 'u_business_service';


  var url = 'kb_find.do?sysparm_search=' + escape(searchText);


  url += "&sysparm_nameofstack=kbpop";


  url += "&sysparm_kb_search_table=incident"; //This example runs on the Incident table. Edit the table name as necessary


  url += "&sysparm_operator=IR_AND_OR_QUERY"; //Tries an 'AND' exact match query and uses an 'OR' query if no exact match


  //url += "&sysparm_operator=IR_OR_QUERY"; //Searches using an 'OR' query


  //url += "&sysparm_operator=IR_AND_QUERY"; //Searches using an 'AND' query


  popupOpenStandard(url, "kb2task");


}



Please try and let me know the outcome



Regards,


Solutioner


Many thanks, just what I wanted.