Making the Coveo Lightning Components Lightning Locker Compliant

Coveo for Salesforce 2.41 (May 2017)

As of the May 2017 release of Coveo for Salesforce (2.41), the Coveo Lightning components can be Lightning Locker compliant (see Coveo for Salesforce Overview).

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

  • You are 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, it is not recommended to go in production with it.

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

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

Change data-condition to data-field

Previous versions of the Coveo 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 are not supported when Lightning Locker is activated. You need to use HTML templates instead.

Recommended Articles