Configuring External Search Source in Employee Center

MichaelCreatura
Tera Guru

 

Hello,


Following this article - https://docs.servicenow.com/bundle/tokyo-servicenow-platform/page/build/service-portal/task/search-s... I have created the below Search Source to lookup Knowledge Articles in another instance of ServiceNow we use. 

 

MichaelCreatura_0-1681912536332.png


Below is the content in the article that I have pasted into the 'data fetch script field', the highlighted I will change the name of the instance I would like to refer to.

 

MichaelCreatura_1-1681912622814.png

 

Do I need to add anything else to the data fetch script? I have been given a username and password service account to access but I am unsure where this goes. 

This is what I have in the 'facet generation script' field:

MichaelCreatura_0-1681913065641.png

 

Thank you for any assistance! 

1 ACCEPTED SOLUTION

does your user have sufficient roles to read those article in the question now. So can you confirm what all your user has (in external system)?

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

View solution in original post

13 REPLIES 13

sushantmalsure
Mega Sage
Mega Sage

as per same documentation , your data fetch script is missing following after execute() and before returning results

if (jsonOutput) {  
        var response = new JSON().decode(jsonOutput.getBody());  
        results = response.result;  
        results.forEach(function(result) {  
            result.url = "https://myInstance.service-now.com/kb_view.do?sysparm_article=" + result.number;            
            result.target = "_blank";  
            result.primary = result.short_description;  
        });  
    }  

    if (jsonOutput.haveError()){
        gs.addErrorMessage(jsonOutput.getErrorMessage());
    }
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Thanks @sushantmalsure I have added it as explained and get the below error:

MichaelCreatura_0-1681916095072.png

Do you also know where I need to add the username and password for authentication?

Thanks! 

well that's not error it must be warning. If you hover on that icon you will get it.

user name and password you are using it here  : 

 

ws.setBasicAuth("search_user", "search"); 

 

 

user name: search_user and password 'search'. You may want to update it as per your user who has access to other servicenow instance

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

This is the warning:

 

MichaelCreatura_0-1681917500578.png

Okay, so I will put the username where the "search_user" is and the password where the "search" is and as long as they are in the sys_user table on the instance I am searching it will authenticate?