Define a search source
- UpdatedApr 3, 2025
- 4 minutes to read
- Vancouver
- Service Portal Designer
Configure a basic search source to query data from an instance table, or configure an advanced data fetch script to query data across multiple tables and data sources, or to pull data from anywhere on the web.
Before you begin
Role required: admin
Procedure
- In the platform UI, navigate to Service Portal > Portals and select the portal you want to add search sources to.
- From the Search Sources related list, click New to add a search source.
-
Define the fields on the Search Source form.
Table 1. Search Source form Field Description Name The display value for the search category. ID The record ID. The value should be unique, and should not include any spaces or special characters. Application The scope of the search source. Roles If the Service Portal User Criteria Support plugin is not enabled, define user roles to access this search source. Search page template The HTML template that displays the search results. If defining a basic search source, you do not need to change the default template.
For an example of a modified template, see Tutorial: set up an external knowledge base search source.
-
Complete the fields on the Data Source tab.
Field Description Is scripted source Adds an advanced data fetch script. If configuring an instance table as the data source, do not check this option. Data fetch script Script defining the endpoint and API calls to fetch data. This field is only visible when Is scripted source is selected.
For an example of a data fetch script, see Tutorial: set up an external knowledge base search source.
Note: If defining a facet generation script, inject the facets object into the data fetch script and update the script to generate data for each facet item. For an example, see the Knowledge Base and Service Catalog search sources. Search facets may not behave as expected if integrated into an advanced search source that queries data from a non- ServiceNow site.Facet generation script Script defining search facets for a scripted search source. Enable your end users to filter search results for a more meaningful result set. This field is only visible when Is scripted source is selected.
Note: If defining a facet generation script, inject the facets object into the data fetch script and update the script to generate data for each facet item. For an example, see the Knowledge Base and Service Catalog search sources. Search facets may not behave as expected if integrated into an advanced search source that queries data from a non- ServiceNow site.Table Select a table from the list that you want to draw your results from. You can select any table in the platform. For example, User [sys_user] or Knowledge [kb_knowledge]. Note: Only indexed tables return search results. Learn more: Configure a table for indexing and searching.Conditions Filters results based on defined conditions. For example, Active is True. Primary display field Select which field you want to display on the search results page. For example, Name. Display fields Select additional fields to display on the search results page. For example, User ID, Email, and City. Paginate results Paginates search results. True by default.
If Is scripted source is selected, the value updates to false. To enable pagination for a scripted search source, see Paginate search source results.
Define the maximum number of results per query for the search source in the Search Page widget or Faceted Search widget instance options.
-
Configure Typeahead settings to allow search results to
populate the search field based on user input.
Field Description Enable typeahead Allows typeahead functionality. If you do not want to integrate typeahead into your search source, clear the check box. Advanced typeahead config Optionally add an advanced typeahead script to configure the way search results display. For more information, see Create an advanced typeahead template. Typeahead glyph Adds an icon beside each typeahead result. Page Defines a service portal page to display the selected result. For example, if form is configured, a selected typeahead result opens in a form. - Click Submit.
What to do next
To enable end users to refine search results, Add facets to a simple search source.