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

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

  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.

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.

Reference

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

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.

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>"
    }
    };
}

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 Cloud, 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 Cloud, 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 Cloud.

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.

Recommended Articles