Making the Coveo Lightning components Lightning Locker compliant

In Summer ’17, Lightning Locker was auto-activated for all Salesforce organizations with no option to disable, meaning that Lightning Locker is automatically enabled for components using API version 40 onwards.

Since the May 2018 release of Coveo for Salesforce V3.10, Coveo for Salesforce Lightning components have gradually migrated to be compliant with Lightning Locker.

The following table shows the evolution of Lightning Locker compliance of Coveo for Salesforce Lightning components:

As of the Coveo for Salesforce V4 release, the former Coveo Case Creation, Coveo Search, Coveo Searchbox, and Coveo Base components have been deprecated in favor of newer Lightning Locker compliant components.

To learn how to leverage these new components, see Upgrading from v3 to v4.

Making Earlier Versions of the Coveo for Salesforce Lightning components Lightning Locker compliant

While all components and pages created from Coveo for Salesforce 2.41 onwards are already Lightning Locker compliant out of the box, components and pages created earlier must be updated to become compliant.

  • You’re not encouraged to activate Lightning Locker with Coveo for Salesforce 2.41, as it may affect your integration in unexpected ways.

  • While you can experiment with Lightning Locker activated, we don’t recommended going to production with it.

  • While activating Lightning Locker with Coveo for Salesforce 2.41+ might not seem to affect your search page at first, it’s a good idea to nevertheless perform the changes listed in this section. Not doing so may prevent your search page from working in the future.

  • Remember to perform the changes for all of the Coveo Lightning components in your community.

Change data-condition to data-field

Previous versions of the Coveo-powered search page used data-condition to ensure that the right templates are loaded for the right type of document (see TemplateLoader - condition).

You must replace every data-condition with data-field.

One of your result template uses the following script tag.

<script id="SalesforceAccount" class="result-template" type='text/html' data-condition="raw.objecttype == 'Account'" >

You change the data-condition="raw.objecttype == 'Account'" to its data-field equivalent.

<script id="SalesforceAccount" class="result-template" type='text/html' data-field-objecttype="Account" >

Use Static Resources for Your Customization

Before Lightning Locker, the good practice to include custom code was to add it to a custom Lightning component that wraps the Coveo components.

While this is still a good practice, you should move the custom code in a static resource that you reference in the custom Lightning component (see Adding JavaScript to the Coveo for Salesforce Lightning components with custom code).

Once you have performed these steps, your Coveo for Salesforce integration should be Lightning Locker compliant.

Use HTML Templates Instead of Underscore Templates

Underscore result templates aren’t supported when Lightning Locker is activated. You need to use HTML templates instead.