{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":42409,"path":"platform-user-interface/service-portal/add-table-search-source.md","title":"Define a search source","bundle":null,"doc_type":null,"release":"australia","body":"\n# Define a search source\n\nConfigure 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.\n\n## Before you begin\n\nRole required: admin\n\n## Procedure\n\n1.  In the platform UI, navigate to **Service Portal** &gt; **Portals** and select the portal you want to add search sources to.\n\n2.  From the **Search Sources** related list, click **New** to add a search source.\n\n3.  Define the fields on the **Search Source** form.\n\n<table id=\"table_zxx_n3b_qz\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nName\n\n</td><td>\n\nThe display value for the search category.\n\n</td></tr><tr><td>\n\nID\n\n</td><td>\n\nThe record ID. The value should be unique, and should not include any spaces or special characters.\n\n</td></tr><tr><td>\n\nApplication\n\n</td><td>\n\nThe scope of the search source.\n\n</td></tr><tr><td>\n\nRoles\n\n</td><td>\n\nIf the Service Portal User Criteria Support plugin is not enabled, define user roles to access this search source.\n\n</td></tr><tr><td>\n\nSearch page template\n\n</td><td>\n\nThe HTML template that displays the search results. If defining a basic search source, you do not need to change the default template.\n\n For an example of a modified template, see [Tutorial: set up an external knowledge base search source](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/search-sp-advanced-ext-kb.md).\n\n</td></tr></tbody>\n</table>4.  Complete the fields on the **Data Source** tab.\n\n<table id=\"table_fl5_dc5_nx\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nIs scripted source\n\n</td><td>\n\nAdds an advanced data fetch script. If configuring an instance table as the data source, do not check this option.\n\n</td></tr><tr><td>\n\nData fetch script\n\n</td><td>\n\nScript defining the endpoint and API calls to fetch data. This field is only visible when **Is scripted source** is selected.\n\n For an example of a data fetch script, see [Tutorial: set up an external knowledge base search source](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/search-sp-advanced-ext-kb.md).\n\n **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.\n\n</td></tr><tr><td>\n\nFacet generation script\n\n</td><td>\n\nScript 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.\n\n **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.\n\n</td></tr><tr><td>\n\nTable\n\n</td><td>\n\nSelect 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: .\n\n</td></tr><tr><td>\n\nConditions\n\n</td><td>\n\nFilters results based on defined conditions. For example, Active is True.\n\n</td></tr><tr><td>\n\nPrimary display field\n\n</td><td>\n\nSelect which field you want to display on the search results page. For example, Name.\n\n</td></tr><tr><td>\n\nDisplay fields\n\n</td><td>\n\nSelect additional fields to display on the search results page. For example, User ID, Email, and City.\n\n</td></tr><tr><td>\n\nPaginate results\n\n</td><td>\n\nPaginates search results. True by default.\n\n If **Is scripted source** is selected, the value updates to false. To enable pagination for a scripted search source, see [Paginate search source results](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/paginate-scripted-search-source.md).\n\n Define the maximum number of results per query for the search source in the Search Page widget or Faceted Search widget instance options.\n\n</td></tr></tbody>\n</table>5.  Configure **Typeahead** settings to allow search results to populate the search field based on user input.\n\n    |Field|Description|\n    |-----|-----------|\n    |Enable typeahead|Allows typeahead functionality. If you do not want to integrate typeahead into your search source, clear the check box.|\n    |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](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/advanced-typeahead.md).|\n    |Typeahead glyph|Adds an icon beside each typeahead result.|\n    |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.|\n\n    \\[Omitted image \"basic-typeahead.png\"\\] Alt text: Example Typeahead tab settings. Page field is set to form.\n\n6.  Click **Submit**.\n\n\n## What to do next\n\nTo enable end users to refine search results, [Add facets to a simple search source](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/create-search-filter.md).\n\n-   **[Paginate search source results](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/paginate-scripted-search-source.md)**  \nLimit the number of results that a search source displays at one time to improve performance. End users can load more results as needed.\n-   **[Create an advanced typeahead template](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/advanced-typeahead.md)**  \nConfigure the way typeahead results display with an advanced template.\n-   **[Tutorial: set up an external knowledge base search source](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/search-sp-advanced-ext-kb.md)**  \nDefine an advanced search source to return data from any source on the Internet. To understand the power of search sources, follow this tutorial to set up an external knowledge base search source.\n-   **[Example: set up a GitHub search source](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/search-sp-advanced.md)**  \nSet up an advanced search source that queries data from an external website.\n\n**Parent Topic:**[Zing search in Service Portal](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/zing-search-service-portal.md)\n\n"}}