Background: There’s almost nothing that is customizable in ServiceNow, thanks to the ServiceNow R&D team for the flexibility and scalability. In the recent times I had an exciting requirement; we usually can search third party data from portal search engine by configuring portal search sources, whereas we don’t have that customization in place to search third party data from platform or workspace, search sources customization within platform is confined to ServiceNow tables.

Requirement: My business is maintaining locations in third party server where they have millions of records, and they will be updating the parameters of those records every now and then, because of various developments. So, we had to access such data from there and must store only if it is needed and that must be a typeahead search. After devising for quite some time I have got the following implementation idea.

Implementation: ServiceNow have a cool feature called Remote tables, which are scriptable tables(hence their name contains “st” by default). The data here is not static but is completely dynamic i.e., the records it shows up here are results of scripting in the table definition. It is like an index page or an interface, it won’t store anything at ServiceNow it just displays the results of the scripting, usually we can script for there tables within ServiceNow connecting multiple tables for reporting or for various reasons. Here’s here, I used the scripting feature of Remote table to integrate with third party server to retrieve the required records and add them as records as I type through each letter in my search. I have implemented his in my PDI, and I had used another ServiceNow instance’s (another PDI) location data for POC and to showcase it here.

Remote table Columns of it has been created whichever are needed as per requirement

Remote table definition
Remote table definition has its own API:

v_table – API to access the remote table to add JSON objects as rows or records to the list

v_query – API to access search queries we are sending to the table

Below is the snapshot of code implementation, one can configure it according to their requirements

As the results in this table can’t be accessed to retrieve the details individually, (as Remote Table is just an interface of results) we will be making the unique id of the records from third party as sys_id of the records t ServiceNow. In this case u_location_id is the unique id of the third party data record. Reference External Location field at ServiceNow will be referred to the Remote Table created above, and its dictionary will be configured to allow auto complete making it as a Typeahead search. External Location ID field will be set ith sys_id of the selection the user makes from the search results using client script (usual onChange client script) and it will be saved.

We then can make use of this ID to fetch the results of the individual record using a business rule.

Here’s how it works whenever I search for something in the table my search query will be accessed by Script with the help of v_query, it refreshes for every character I type. Then in the Remote Table definition, he search query will be parsed as required and would be set in the REST API call we make which would fetch the results. The results will be parsed again to add the records to the Remote Table list using v_table. Following road map and gif explains the roadmap of functionality and actual user experience