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

Forgot I'd made changes in Dev and have now cloned live over Dev what field should I update the dictionary attributes for please?



Sure I got this working last week and have now gone blank 😞


amacqueen
Mega Guru

No worries I've got it now 🙂


sai1489
Kilo Explorer

Hello ,


                I have a requirement where in i need to show the knowledge articles both   retired and published articles based on the text given in short description of an incident. I have not been able to customize the code you've given to any good effect . Could you please help me out with this .


Regards,


Sai


davidian
Tera Contributor

What's the purpose of this variable, it doesn't seem to get used anywhere?

var elementName = 'u_business_service';

I'd also like to know how to hide or remove the "Attach to <table>" button that is shown in 'kbpop' popup, but only for this custom search i.e. I don't want to affect existing knowledge searches.

ChandrashekH736
Giga Contributor
  • Description :
    Revise the configuration for the 'Search Knowledge' button to enhance its functionality. Specifically, update the attributes of the 'short_description' field on the Task table to execute custom JavaScript that enables searching across all Knowledge Bases. Currently, it is limited to Knowledge Bases enabled under EMConnect

    Acceptance Criteria :
    The 'Search Knowledge' button must successfully execute a custom JavaScript function that searches all available Knowledge Bases, regardless of their status in EMConnect.
    The attributes of the 'short_description' field on the Task table must be updated to incorporate the new logic.


    Script :
    Add onLoad Client Script:

     


    function onLoad() {
    // You can add any initialization logic here if needed
    return;
    }

    function customKnowledgeSearch() {
    var searchText = g_form.getValue('short_description');
    var elementName = 'u_business_service';
    var url = 'kb_find.do?sysparm_search=' + encodeURIComponent(searchText);
    url += "&sysparm_nameofstack=kbpop";
    url += "&sysparm_kb_search_table=incident"; // Adjust table name if needed
    url += "&sysparm_operator=IR_AND_OR_QUERY"; // Use AND/OR query logic

    popupOpenStandard(url, "kb2task");
    }

     

    The above script is fine for the above description and Acceptance Criteria or any other things to add