Adding the AttachedResults Component

Lightning Experience

Coveo for Salesforce 3 (May 2018)

The AttachedResults component allows your users to see the results they have attached to a specific record using the AttachedToCase result action in the Coveo Insight Panel Lightning Component.

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

As of the March 2020 Maintenance Release (V3.48), the Attached Results and Case Attached Results custom objects support Salesforce Field-Level Security.

As a result, the Attached Results, Case Attached Results, and Case Article object fields must now be visible to agents who perform attach actions for the Attached Results component to work properly (see Set Field Permissions in Permission Sets and Profiles).

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

Since the AttachedResults 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 improve Coveo Usage Analytics (Coveo UA) reporting.

attached-results-component

Adding the AttachedResults Lightning Component to a Record Page

Ensure you have previously integrated the Coveo Insight Panel Lightning Component in your record page before adding the AttachedResults Lightning component.

  1. In Salesforce, access your Lightning Application (e.g., Lightning Service Console, Sales), and then open any record (e.g., Case, Opportunity, Account).

  2. At the top right of the page, click Setup Cogwheel icon, and then select Edit Page.

  3. In the Lightning App Builder, drag and drop the Coveo Attached Results component wherever you want it to appear on the record page.

  4. At the top right, click Save.

Now that you have added the AttachedResults Lightning Component, you should ensure that the AttachToCase result action is properly integrated in your Coveo Insight Panel Lightning Component.

AttachedResults Tab

Ensure you have previously integrated the Coveo Insight Panel Lightning Component in your record page before adding the AttachedResults tab.

The AttachedResults tab can be integrated in 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.

However, since the AttachedResults tab is integrated in the Coveo Insight Panel Lightning Component, it uses the same search hub.

attached-results-tab

Adding the AttachedResults Tab in a Coveo Insight Panel Lightning Component

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

  1. In Salesforce, access your Lightning Application (e.g., Lightning Service Console, Sales), and then open any record (e.g., Case, Opportunity, Account).

  2. At the top right 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, add the following:

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

Now that you have added the AttachedResults Lightning Component, you should ensure that the AttachToCase result action is properly integrated in your Coveo Insight Panel Lightning Component.

Modifying the AttachedResults Tab Name

Once you have included the tab in your Coveo Insight Panel Lightning Component, you can change its display name if needed.

  1. In Salesforce, access your Lightning Application (e.g., Lightning Service Console, Sales), and then open any record (e.g., Case, Opportunity, Account).

  2. At the top right 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 section with the name you want for the tab:

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

Default value is Attached results.

AttachToCase Result Action

In order to take advantage of the AttachedResults component or AttachedResults tab, you must configure the AttachToCase result action in your Coveo Insight Panel Lightning Component.

You can use the AttachToCase result action without integrating the AttachedResults component or AttachedResults tab in your interface.

The AttachToCase result action adds a paperclip 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 Yellow-Paperclip icon.

attach-to-case-result-action

Adding the AttachedToCase Result Action to a Coveo Insight Panel Lightning Component

  1. In Salesforce, access your Lightning Application (e.g., Lightning Service Console, Sales), and then open any record (e.g., Case, Opportunity, Account).

  2. At the top right 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, ensure the following string is present:

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

Attached Result Custom Object

When an agent clicks the AttachToCase 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 attach actions usage.

By default, the Attached Result custom object stores the value of the following item fields:

  • CreatedById

  • Name

  • LastModifiedById

  • OwnerId

  • CoveoV2__RecordId__c

  • CoveoV2__ResultUrl__c

  • CoveoV2__Source__c

  • CoveoV2__Title__c

  • CoveoV2__UriHash__c

Adding Fields to the Attached Result Custom Object

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

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

  1. In Salesforce, in 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 your Coveo Insight Panel Lightning component Code View tab:

    1. Click the cogwheel 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
     });
    

    The arg variable contains 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. Save your page by selecting Save.

  9. The only thing left to do is to 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

If you want to integrate the AttachedResults Lightning Component in 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>

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 error 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 your 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

Coveo for Salesforce 3.42 (November 2019)

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

Default value is false.

Attached Results Tab 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

This component must be added in your Coveo Insight Panel Lightning Component.

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

AttachToCase Result Action Reference

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 for Coveo Cloud V2 and Managing Fields for a Source for Coveo Cloud V1).

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>
Recommended Articles