Use Extension Points to Customize Your Deployment

Coveo for ServiceNow comes with an extension point 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.

Create an Implementation

  1. Navigate to System Extension Points > Scripted Extension Points.

  2. 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 section.

  3. 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.

  4. On the page that opens, you can edit the implementation script or replace it with your own custom script.

Should you encounter errors or unexpected behaviors with your implementation, reach out to Coveo Support for help.

Reference

The Coveo for ServiceNow extension point contains several functions that you can use to customize your end users' search experience.

  • getJsUiOptions allows you to add custom JavaScript Search Framework options to your widgets.

  • getJsUiTranslations allows you to provide custom translations to display in your Coveo for ServiceNow search interfaces.

  • getJsUiCultureMap 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 allows you to add custom, additional data to the context sent to Coveo along with queries.

  • getFieldsToIgnore allows you to specify record form fields whose content shouldn’t be sent to Coveo.

getJsUiOptions (Function)

You can use the getJsUiOptions function to set custom properties for the search interface widgets. 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 for details on this process.

Note

The getJsUiOptions function applies your customization to all widgets in your Coveo for ServiceNow deployment. If you want to add an option to a certain widget only, use the widgetOptions attributes to specify a function condition.

Example:

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 for details.

Example:

getJsUiTranslations: function getJsUiTranslations(widgetOptions) {
    return {
    en: {
        AreYouSureDeleteFilter: "Are you sure you want to delete the filter {0} with the expression {1}",
        Results: "Result<pl>s</pl>"
    }
    };
}

getJsUiCultureMap (Function)

The getJsUiCultureMap function allows you to add custom mapping between a ServiceNow language ID and a Coveo JavaScript Search Framework language culture file key.

Coveo for ServiceNow search interfaces leverage the default localized strings in the Coveo JavaScript Search Framework. By default, a Coveo search interface displays the localized strings that correspond to the current user’s language in ServiceNow based on a preconfigured mapping between ServiceNow language IDs and Coveo JavaScript Search Framework language culture file keys.

If you need to add a custom mapping that is not 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 is not supported in the default mapping for Coveo for ServiceNow, you map it to the corresponding culture file key (en) in the Coveo JavaScript Search Framework as follows:

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.

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 or by Coveo Machine Learning. By default, the query already contains some information about the user, but it can be enriched thanks to this function.

Example:

getCustomContext: function getCustomContext(widgetOptions, userContext) {
    userContext["company_name"] = "Coveo";
    return userContext;
}

WidgetOptions:

  1. scope (string, optional): The scope under which you want to categorize the function. This parameter work similarly to the Scope widget option.

  2. component (string, optional): The component under which you want to categorize the function. This parameter work similarly to the Component widget option.

  3. searchPageId (string, optional): The ID of the ServiceNow page template in which you embedded the Main Search widget. 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 in a record form.

By default, editing the content of any record form field triggers a query to Coveo, which in turn updates the Insight Panel. Moreover, the content of all form fields is sent as context information for Coveo Machine Learning (Coveo ML) purposes.

If you want 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.

Example:

getFieldsToIgnore: function(widgetOptions) {
        return ['priority', 'cmdb_id'];
    },

WidgetOptions:

  1. scope (string, optional): The scope under which you want to categorize the function. With this function, it should be InsightPanel (widgetOptions.scope == 'InsightPanel').

  2. component (string, optional): The component under which you want to categorize the function. This parameter work similarly to the Component widget option.

  3. searchPageId (string, optional): The ID of the ServiceNow page template in which you embedded the Main Search widget. Users will be redirected to this page to view their search results.

What's next for me?