Add the Attached Results component

The Coveo Attached Results component lets users see the results they have attached to a specific record using the Attach to case result action in the Coveo Insight Panel Lightning Component.

Coveo for Salesforce currently offers two distinct options to integrate the Attached Results component into a Salesforce record page:

Important
Important

The Attached Results Lightning component is a distinct Lightning component that can be placed anywhere in the Salesforce console.

Since the Attached Results Lightning component is an independent component, it has its own search hub name. This is particularly useful to take advantage of Coveo Machine Learning (Coveo ML) and to improve Coveo Usage Analytics (Coveo UA) reporting.

Attached Results component | Coveo for Salesforce

Add the Attached Results Lightning component to a record page

  1. Integrate the Coveo Insight Panel Lightning Component in your record page.

  2. Access your Lightning Application (for example, the Lightning Service Console), and then open any record (for example, a case).

  3. In the upper-right corner of the page, click Setup (the gear icon), and then select Edit Page.

  4. In the Lightning App Builder, drag the Coveo Attached Results component to the location you want it to appear on the record page, and then click Save.

Now that you’ve added the Attached Results Lightning component, add the Attach to Case result action to your Coveo Insight Panel Lightning Component if it isn’t already included.

Attached Results tab

You can integrate the Attached Results tab into the Coveo Insight Panel Lightning Component. It appears as a distinct tab with which your agents can interact to see the results they have attached to a specific record.

Attached Results tab | Coveo for Salesforce
Note

Since the Attached Results tab is integrated into the Coveo Insight Panel Lightning Component, it uses the same search hub.

Add the Attached Results tab in a Coveo Insight Panel Lightning Component

Note

If you’re using the Salesforce Classic experience, the Attached Results tab is automatically integrated into your Coveo Insight Panel Classic Component.

  1. Integrate the Coveo Insight Panel Lightning Component in your record page.

  2. Access your Lightning Application (for example, the Lightning Service Console), and then open any record (for example, a case).

  3. In the upper-right corner of the Coveo Insight Panel Lightning Component, click Setup, and then select Edit.

  4. In the Interface Editor that appears, select the Code View tab.

  5. In the <div class="coveo-tab-section"> section, add the following:

    <a class="CoveoAttachedResultsTab" data-id="AttachedResults" data-caption="Attached results"></a>

Now that you’ve added the Attached Results tab, add the Attach to Case result action to your Coveo Insight Panel Lightning Component if it isn’t already included.

Modify the name of the Attached Results tab

After adding the Attached Results tab to your Coveo Insight Panel Lightning Component, you can change its display name if necessary.

  1. Access your Lightning Application (for example, the Lightning Service Console), and then open any record (for example, a case).

  2. In the upper-right corner of the Coveo Insight Panel Lightning Component, click Setup, and then select Edit.

  3. In the Interface Editor that appears, select the Code View tab.

  4. In the <div class="coveo-tab-section"> section, replace the data-caption value with the name you want to use, for example:

    <a class="CoveoAttachedResultsTab" data-id="AttachedResults" data-caption="<MY_TAB_NAME>"></a>

    Where you replace <MY_TAB_NAME> with the name you want for your tab.

    The default value is Attached results.

Attach to case result action

To use the Attached Results component or the Attached Results tab, you must configure the Attach to case result action in your Coveo Insight Panel Lightning Component.

Note

You can use the Attach to case result action without integrating the Attached Results component or Attached Results tab in your interface.

The Attach to case result action adds a paperclip icon to the items suggested in the Coveo Insight Panel Lightning Component. Agents can attach those items to any Salesforce object by clicking the paperclip icon.

Attached items have a yellow paperclip icon.

Attach to case result action | Coveo for Salesforce

Add the Attach to case result action to a Coveo Insight Panel Lightning Component

  1. Access your Lightning Application (for example, the Lightning Service Console), and then open any record (for example, a case).

  2. In the upper-right corner of the Coveo Insight Panel Lightning Component, click Setup, and then select Edit.

  3. In the Interface Editor that appears, select the Code View tab.

  4. In the <div class="CoveoResultActionsMenu"> section, add the following string if it isn’t already included:

    <div class="CoveoAttachToCase"></div>

Attached Result custom object

When an agent clicks the Attach to case result action to attach a search result to a Salesforce object, the Coveo Attached Result custom object stores information on the attach actions performed by the agent. This custom object is useful when you want to report on the usage of attach actions.

By default, the Attached Result custom object stores the following item field values:

  • CreatedById

  • Name

  • LastModifiedById

  • OwnerId

  • CoveoV2__RecordId__c

  • CoveoV2__ResultUrl__c

  • CoveoV2__Source__c

  • CoveoV2__Title__c

  • CoveoV2__UriHash__c

  • CoveoV2__PermanentId__c

Important
Important

To avoid field access errors, you must set field permissions on the CoveoV2__PermanentId__c item field after installing Coveo for Salesforce (v4.20) or later releases.

Add fields to the Attached Result custom object

You may want to add additional metadata to your Attached Result custom object to get more information on the attach actions performed by your agents.

To achieve this, you must create new fields in the Attached Result custom object:

  1. In Salesforce Setup, search for and select Object Manager.

  2. Under Label, select Attached Result, and then select Fields & Relationships.

  3. On the Asset Relationship page, select Fields & Relationships.

  4. On the Fields & Relationships page, click New to add a new field.

  5. Create your new field.

  6. Access the Code View tab in your Coveo Insight Panel Lightning Component:

    1. Click the gear icon in the upper-right corner of your Coveo Insight Panel Lightning Component, and then select Edit.

    2. In the interface that opens, select the Code View tab.

  7. In your page, in a script tag, add the following code. Remember to change myCustomField__c and myCustomField2__c with your Field Name, as displayed in the Field Name column of the Salesforce Fields & Relationships page for the Attached Result custom object.

    $("#search").on(Coveo.UserActionEvents.attachToCase, function(e, arg) {
      arg.dataToAttach.customs["myCustomField__c"] = "myCustomValue"; // You can use static values
      arg.dataToAttach.customs["myCustomField2__c"] = arg.result.raw.myField; // Or use value from one of your result field
    });
    Note

    The arg variable contains the following two objects:

    • dataToAttach contains the default data that will be added to the new AttachedResult object.

    • result contains additional data about the current result.

  8. Click Save.

  9. Ensure that your custom field is displayed in your console Case Layout (see Edit Page Layouts for Standard Objects).

Reference

AttachedResults Lightning component reference

Usage

To integrate the Attached Results Lightning component into another custom Lightning component, reference it in your Lightning component as you would for any other Aura component, using the namespace prefix of the Coveo package (see Create Aura Components in the Developer Console).

<aura:component implements="force:hasRecordId,flexipage:availableForRecordHome" access="global">
  <CoveoV2:AttachedResults recordId="{!v.recordId}" />
</aura:component>
Note

When wrapping the component, specify the recordId option to avoid any page initialization failures. The recordId option is required to know which record you’re viewing and to retrieve the right attachments for the current record.

Resources included with this component

This component includes the Coveo JavaScript Search Framework, the jQuery (latest 3.x.x version) and Underscore.js (latest 1.x.x version) libraries, and the Coveo for Salesforce specific assets.

Aura event

This component offers the ErrorEvent event.

This event is fired when an error occurs with the component.

Options

This component offers the following options:

title

The title to show at the top of the component.

Default value is Attached Results.

name

The name of the Visualforce component that should act as the search interface for your Coveo Insight Panel Lightning Component.

Default value is coveoAttachedResults.

searchHub

The name of the searchHub used by Coveo Usage Analytics (Coveo UA), the query pipeline, and Coveo Machine Learning.

This option should have the same value as name.

debug

Whether to use the non-minified versions of the different resources.

Default value is false.

AttachedResultsTab reference

Options

This component has the same options as the Tab component (see Coveo Component Tab).

Methods

This component doesn’t provide any methods.

Usage

<a class="CoveoAttachedResultsTab" data-id="AttachedResults" data-caption="Attached results">
</a>

AttachToCase result action reference

Important
Important

When you want to attach Knowledge articles, ensure that the sfkbid, sfkbversionnumber, and sflanguage fields are properly populated on the article (see Manage source mappings).

Options

This component offers the following options:

displayText

Specifies if the component should include the Attach/Detach text.

The default value is true.

<div data-display-text="true"/>
readonly

Specifies if the component should be in read only mode. When in read only mode, you can’t Attach or Detach results.

The default value is false.

<div data-readonly="true"/>

Methods

This component provides the following methods:

attach

Attaches the result to the current Case.

$('#myAttachToCase').coveo('attach')
detach

Detaches the result from the current Case.

$('#myAttachToCase').coveo('detach')
isAttached

Returns whether the result is attached.

$('#myAttachToCase').coveo('isAttached')

Usage

<div class="CoveoAttachToCase"></div>