--- title: Use extension points to customize your deployment slug: '3227' canonical_url: https://docs.coveo.com/en/3227/ collection: coveo-for-servicenow source_format: adoc --- # Use extension points to customize your deployment Coveo for ServiceNow comes with an [extension point](https://www.servicenow.com/docs/bundle/zurich-governance-risk-compliance/page/product/grc-rcm/concept/extension-points.html) allowing you to extend some aspects of the Coveo functionality. This feature contains methods that make it possible to: * Add custom JavaScript Search Framework options to your widgets. * Add custom mapping between a ServiceNow language ID and a Coveo JavaScript Search Framework language culture file key for localization of Coveo for ServiceNow search interfaces. * Provide custom translations to display in your Coveo for ServiceNow search interfaces. * Add custom, additional data to the context sent to Coveo along with queries. * Customize the fields that trigger or don't trigger a query when using the Insight Panel. * Modify the payload when generating an authentication search token from the Insight Panel search interface. ## Create an implementation . Navigate to **System Extension Points** > **Scripted Extension Points**. . On the **Extension Points** page, click the extension whose name ends with `coveo_1_0.CoveoExtensions`. This is a built-in example of the available methods. For details on these methods, see the [Reference](#reference) section. . On the **CoveoExtensions** extension point page, under **Related Links**, click **Create implementation**. > **Note** > > Although you can create several implementations for the Coveo extension point, you can't create two implementations that contain the same method. > You must instead add condition to your method to ensure it applies as desired. . On the page that opens, you can edit the implementation script or replace it with your own custom script. If you encounter errors or unexpected behaviors with your implementation, reach out to [Coveo Support](https://connect.coveo.com/s/case/Case/Default) for help. ## Reference The Coveo for ServiceNow extension point contains several functions that you can use to customize your end users' search experience. * [`getJsUiOptions`](#getjsuioptions-function) allows you to add custom [JavaScript Search Framework](https://docs.coveo.com/en/375/) options to your widgets. * [`getJsUiTranslations`](#getjsuitranslations-function) allows you to provide custom translations to display in your Coveo for ServiceNow search interfaces. * [`getJsUiCultureMap`](#getjsuiculturemap-function) allows you to create a custom mapping between a ServiceNow language ID and a Coveo JavaScript Search Framework language culture file key for localization of Coveo for ServiceNow search interfaces. * [`getCustomContext`](#getcustomcontext-function) allows you to add custom, additional data to the context sent to Coveo along with queries. * [`getFieldsToIgnore`](#getfieldstoignore-function) allows you to specify record form fields whose content won't be sent to Coveo. * [`getFieldsToInclude`](#getfieldstoinclude-function) allows you to specify record form fields whose content will be sent to Coveo. * [`getRecordCreator`](#getrecordcreator-function) allows you to modify the record creator value that's used to fetch the user on which to base Insight Panel User Actions. * [`getSearchTokenRequestBody`](#getsearchtokenrequestbody-function) allows you to modify the body of the request that's sent to generate a search token for authentication. ### `getJsUiOptions` (function) You can use the `getJsUiOptions` function to set custom properties for the search interface [widgets](https://docs.coveo.com/en/2853/). The function returns a JavaScript object that Coveo for ServiceNow uses to set the properties of a Coveo for ServiceNow search interface while initializing it. See [Passing Component Options in the `init` Call](https://docs.coveo.com/en/346#passing-component-options-in-the-init-call) for details on this process. > **Note** > > The `getJsUiOptions` function applies your customization to all widgets in your Coveo for ServiceNow deployment. > To add an option to a certain widget only, use the `widgetOptions` attributes to specify a function condition. **Example** ```javascript getJsUiOptions: function getJsUiOptions(widgetOptions) { if (widgetOptions.scope == 'CustomerServicePortal' && widgetOptions.component == 'FullSearchPage') { return { Pager: { numberOfPages: 9 } }; } return {}; } ``` ### `getJsUiTranslations` (function) The `getJsUiTranslations` function allows you to customize the localization of the search interface widget. This function returns a dictionary of key/value pairs for each language. You might encounter some particular situations while applying your customizations. See [Special Cases](https://docs.coveo.com/en/1798#special-cases) for details. **Example** ```javascript getJsUiTranslations: function getJsUiTranslations(widgetOptions) { return { en: { AreYouSureDeleteFilter: "Are you sure you want to delete the filter {0} with the expression {1}", Results: "Results" } }; } ``` ### `getJsUiCultureMap` (function) The `getJsUiCultureMap` function allows you to add custom mapping between a [ServiceNow language ID](https://www.servicenow.com/docs/bundle/zurich-platform-administration/page/administer/localization/reference/r_LanguagesTable.html) and a [Coveo JavaScript Search Framework](https://docs.coveo.com/en/187/) [language culture file key](https://docs.coveo.com/en/421#built-in-languages). Coveo for ServiceNow search interfaces leverage the [default localized strings in the Coveo JavaScript Search Framework](https://docs.coveo.com/en/421/). By default, a Coveo-powered search interface displays the localized strings that correspond to the current user's language in ServiceNow based on a [preconfigured mapping](https://docs.coveo.com/en/3227#default-localization-mapping) between ServiceNow language IDs and Coveo JavaScript Search Framework language culture file keys. If you must add a custom mapping that isn't supported by default, such as to support a new language ID in ServiceNow or a new language culture file in Coveo JavaScript Search Framework, you can do so using the `getJsUiCultureMap` function. **Example** You created a new `en-us` language record in ServiceNow. Since `en-us` isn't supported in the [default mapping](https://docs.coveo.com/en/3227#default-localization-mapping) for Coveo for ServiceNow, you map it to the corresponding culture file key (`en`) in the Coveo JavaScript Search Framework as follows: ```javascript getJsUiCultureMap(defaultMap) { defaultMap['en-us'] = 'en'; return defaultMap; } ``` #### Default localization mapping The following table shows the default mapping between the ServiceNow language IDs and the Coveo JavaScript Search Framework language culture file keys. [cols="3",options="header"] |=== |Language |ServiceNow language ID |Coveo culture file key |English |en |en |French |fr |fr |French (Quebec) |fq |fr |Chinese (Simplified) |zh |zh-cn |Czech |cs |cs |Dutch |nl |nl |Finnish |fi |fi |German |de |de |Hungarian |hu |hu |Italian |it |it |Japanese |ja |ja |Korean |ko |ko |Norwegian |nb |no |Polish |pl |pl |Portuguese (Brazil) |pt |pt-br |Russian |ru |ru |=== ### `getCustomContext` (function) The `getCustomContext` function allows you to inject additional user context in a query. This information can then be leveraged in Usage analytics [reports](https://docs.coveo.com/en/266/) or by [Coveo Machine Learning](https://docs.coveo.com/en/188/). By default, the query already contains some information about the user, but it can be enriched thanks to this function. **Example** ```javascript getCustomContext: function getCustomContext(widgetOptions, userContext) { userContext["company_name"] = "Coveo"; return userContext; } ``` #### widgetOptions The following table lists the options for the `getCustomContext` function. [cols="2",options="header"] |=== |Option |Description |`scope` (string, optional) |The [scope](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Coveo search interface widget](https://docs.coveo.com/en/2852/). |`component` (string, optional) |The [component](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Coveo search interface widget](https://docs.coveo.com/en/2852/). |`searchPageId` (string, optional) |The ID of the ServiceNow page template in which you [embedded the Main Search widget](https://docs.coveo.com/en/2105/). Users will be redirected to this page to view their search results. |=== ### `getFieldsToIgnore` (function) You can use the `getFieldsToIgnore` function when [implementing the Insight Panel](https://docs.coveo.com/en/2113/). By default, editing the content of any record form field triggers a [query](https://docs.coveo.com/en/231/) to Coveo, which in turn updates the Insight Panel. Moreover, the content of all form fields is sent as [context](https://docs.coveo.com/en/1345/) information for [Coveo Machine Learning (Coveo ML)](https://docs.coveo.com/en/188/) purposes. To avoid triggering a query when some fields are edited frequently or contain irrelevant data, or if some fields contain sensitive data that you don't want to send to Coveo, the `getFieldsToIgnore` function allows you to filter the fields to send. In other words, you can create a list of the field you don't want to send to Coveo. In the returned array, list the fields that shouldn't trigger a query and be sent as context information. > **Note** > > Instead of listing the fields to ignore, you can list the fields that will trigger a query and be sent as context information by using the [`getFieldsToInclude`](#getfieldstoinclude-function) function. **Example** ```javascript getFieldsToIgnore: function(widgetOptions) { return ['priority', 'cmdb_id']; }, ``` #### widgetOptions The following table lists the options for the `getFieldsToIgnore` function. [cols="2",options="header"] |=== |Option |Description |`scope` (string, optional) |The [scope](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Insight Panel](https://docs.coveo.com/en/2113/). |`component` (string, optional) |The [component](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Insight Panel](https://docs.coveo.com/en/2113/). |`searchPageId` (string, optional) |The ID of the ServiceNow page template in which you [embedded the Main Search widget](https://docs.coveo.com/en/2105/). Users will be redirected to this page to view their search results. |=== ### `getFieldsToInclude` (function) You can use the `getFieldsToInclude` function when [implementing the Insight Panel](https://docs.coveo.com/en/2113/). By default, editing the content of any record form field triggers a [query](https://docs.coveo.com/en/231/) to Coveo, which in turn updates the Insight Panel. Moreover, the content of all form fields is sent as [context](https://docs.coveo.com/en/1345/) information for [Coveo Machine Learning (Coveo ML)](https://docs.coveo.com/en/188/) purposes. Use the `getFieldsToInclude` function to trigger a query only when certain fields are edited. In the returned array, list the fields that will trigger a query and be sent as context information. > **Note** > > Instead of listing the fields to include, you can list the fields to ignore that won't trigger a query and be sent as context information by using the [`getFieldsToIgnore`](#getfieldstoignore-function) function. **Example** ```javascript getFieldsToInclude: function(widgetOptions) { return ['short_description', 'category']; }, ``` #### widgetOptions The following table lists the options for the `getFieldsToInclude` function. [cols="2",options="header"] |=== |Option |Description |`scope` (string, optional) |The [scope](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Insight Panel](https://docs.coveo.com/en/2113/). |`component` (string, optional) |The [component](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Insight Panel](https://docs.coveo.com/en/2113/). |`searchPageId` (string, optional) |The ID of the ServiceNow page template in which you [embedded the Main Search widget](https://docs.coveo.com/en/2105/). Users will be redirected to this page to view their search results. |=== ### `getRecordCreator` (function) You can use the `getRecordCreator` function when [implementing the Insight Panel](https://docs.coveo.com/en/2113/). The `getRecordCreator` function lets you modify the record creator value that's used to fetch the user on which to base the Insight Panel [User Actions](https://docs.coveo.com/en/2113#user-actions). Typically, the actions that appear in User Actions are associated with the customer who opened the incident or case. By default, the Insight Panel fetches the email address of the user that's specified in the `opened by` record form field, as set in the Insight Panel's **Table Creator Field** ([Configurable Workspace](https://docs.coveo.com/en/2113#configurable-workspace)) or **tableCreatorField** ([Agent Workspace](https://docs.coveo.com/en/2113#agent-workspace)) configuration. Use the `getRecordCreator` function to overwrite the table creator value that's configured for the Insight Panel so that it fetches the user based on custom criteria, such as a user name instead of an email address. > **Note** > > [Dot-walking](https://developer.servicenow.com/dev.do#!/learn/courses/zurich/app_store_learnv2_scripting_zurich_scripting_in_servicenow/app_store_learnv2_scripting_zurich_server_side_scripting/app_store_learnv2_scripting_zurich_dot_walking) syntax is supported. **Example** ```javascript getRecordCreator: function getRecordCreator(widgetOptions) { if (!widgetOptions.tableName || !widgetOptions.recordSysId) { return; } var record = new GlideRecord(widgetOptions.tableName); record.get(widgetOptions.recordSysId); var hashedUserName = btoa(record.getElement('opened_by.user_name').toString()); return hashedUserName; } ``` #### widgetOptions The following table lists the options for the `getRecordCreator` function. [cols="2",options="header"] |=== |Option |Description |`scope` (string, optional) |The [scope](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Insight Panel](https://docs.coveo.com/en/2113/). |`component` (string, optional) |The [component](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Insight Panel](https://docs.coveo.com/en/2113/). |`searchPageId` (string, optional) |The ID of the ServiceNow page template in which you [embedded the Main Search widget](https://docs.coveo.com/en/2105/). Users will be redirected to this page to view their search results. |`tableName` (string, optional) |The table name of the current record. |`recordSysId` (string, optional) |The system ID of the current record. |`tableCreatorField` (string, optional) |The value of the table creator field parameter. |=== ### `getSearchTokenRequestBody` (function) You can use the `getSearchTokenRequestBody` function when [implementing the Insight Panel](https://docs.coveo.com/en/2113/). The `getSearchTokenRequestBody` function allows you to modify the body of the request when [generating an authentication search token](https://docs.coveo.com/en/56/) from a Coveo Insight Panel search interface in ServiceNow. This is useful, for instance, to anonymize or edit the identity of users. By default, the payload is the email address of the logged-in user in the ServiceNow instance. **Example** ```javascript getSearchTokenRequestBody: function getSearchTokenRequestBody(tokenBody, scope, component, seeProfileOf) { tokenbody.userIds = [ { name: `asmith@example.com`, provider: `Email Security Provider`, type: `User` } ]; return tokenBody; }; ``` #### Options The following table lists the options for the `getSearchTokenRequestBody` function. [cols="2",options="header"] |=== |Option |Description |`tokenBody` (object, optional) |The body of the request. See [Request body properties](https://docs.coveo.com/en/56#request-body-properties) for options. |`scope` (string, optional) |The [scope](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Insight Panel](https://docs.coveo.com/en/2113/). |`component` (string, optional) |The [component](https://docs.coveo.com/en/3198#establish-a-widget-naming-convention) of the [Insight Panel](https://docs.coveo.com/en/2113/). |`seeProfileOf` (object, optional) |The user identifier in ServiceNow that's used to retrieve [User Actions](https://docs.coveo.com/en/2113#user-actions). |===