The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jesseadams
ServiceNow Employee
ServiceNow Employee

The Istanbul release introduced a new feature in Service Portal called search sources. This is a pretty powerful feature and there is not a lot of information out there about it yet so my hope here is to share what I have learned so far by walking through an example of how to implement one. This will be a two-part series. In part one, we will learn what a search source is and how to create a simple non-scripted search source. To use search sources, you just need to be using Service Portal and be on the Istanbul release.

First, what is a search source? Search sources are kind of like the Service Portal version of search groups but they're more robust. Search sources allow you to configure where a search in your portal will look for data. This can be a set of tables in your instance or resources external to your instance or a combination of the two. Essentially, this could allow you to configure a single search in your portal that will search all of your organizations resources in one place.

Search sources are linked to a portal through a many to many table (m2m_sp_search_source) so once you create one it can be re-used in any portal.

How to create a new non-scripted Search Source

To create a new search source, start at your portal record. There is a new related list for search sources on this form. If you do not see it you'll need to add it to the form manually. Once you see that list, click the new button and let's create a new search source.

There are two kinds of search sources: Scripted and non-scripted.

  • Scripted search sources allow us to write a script to search an external site or write more advanced queries than the condition builder would allow in a non-scripted search source.
  • Non-scripted search sources function very similarly to search groups from the native UI. This lets you specify a table and build a filter to control what records can be returned in the result set.

There are several things required for a search source to work:

  1. Name: this is the name that will be displayed on the search results page
  2. ID: this is a unique identifier for your search source
  3. Search Page Template: this determines how the search results will be displayed and where the link to open the result will take you
  4. Data Source: This can be scripted or not depending on the "Is Scripted Source" checkbox. Based on that selection you'll see either a table select box and filter builder or a script field.
  5. (optional) A page and widget to display your external content.

Example of a non-scripted search source to find incidents

Let's start with a non-scripted search source to search for incidents from the service portal, then we'll move on to a scripted one in part two. We're going to give our example the name "Incidents" and ID incident_search because we want to search for incidents from the service portal.

  1. Navigate to the portal form.
  2. Click New in the related list for search sources to open the search source form.

    Since we're only displaying internal content and we want to open the records returned in the form view we'll leave the search page template with the default code. We'll look more in depth at this later when we look at scripted sources but for now this provides exactly the functionality we need, so we'll leave it.nonscriptsearchsource1.jpg

  3. Next, we'll configure the data source.
    • Table: Incident — this is the table we're searching
    • Conditions: active is true — this lets us control what records are returned by the search
    • Primary display field: number - This is the title displayed in our search results
    • Display fields: short_description — this lets us display fields other than our primary in the search result template.datasource1.jpg
  4. Save the record

Now, we can try out our search source and see how it works! To do this, simply go to your portal home page and search for something like "Email." You should see the results displayed like this:

searchsources.jpg

You see our "Incidents" search source is displayed and we have two results. Clicking on these will open the incident in the default form page for the service portal.

That wraps up our intro to search sources. In part two, we'll explore scripted search sources and walk through and example of creating one. For more information on search sources, see Configure search in Service Portal.

24 Comments