Adding the AttachedResults component
Adding the AttachedResults component
Lightning Experience
Coveo for Salesforce 3 (May 2018)
The AttachedResults component lets users 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:
-
Using the AttachedResults Lightning component (recommended)
-
Using the AttachedResults tab in the Coveo for Salesforce Insight Panel
-
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).
-
As of the November 2021 release of Coveo for Salesforce (v4.20), the Attached Result custom object also stores the value of the
CoveoV2__PermanentId__c
item field (see About the PermanentId field). Going forward, this item field will be used instead of theCoveoV2__UriHash__c
when storing the attach actions performed by an agent.To avoid field access errors, you must set field permissions on the
CoveoV2__PermanentId__c
item field.
AttachedResults Lightning component (recommended)
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.
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.
-
In Salesforce, access your Lightning Application (e.g., Lightning Service Console, Sales), and then open any record (e.g., Case, Opportunity, Account).
-
At the top right of the page, click Setup
, and then select Edit Page.
-
In the Lightning App Builder, drag and drop the Coveo Attached Results component wherever you want it to appear on the record page.
-
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.
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.
-
In Salesforce, access your Lightning Application (e.g., Lightning Service Console, Sales), and then open any record (e.g., Case, Opportunity, Account).
-
At the top right of the Coveo Insight Panel Lightning Component, click Setup, and then select Edit.
-
In the Interface Editor that appears, select the Code View tab.
-
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.
-
In Salesforce, access your Lightning Application (e.g., Lightning Service Console, Sales), and then open any record (e.g., Case, Opportunity, Account).
-
At the top right of the Coveo Insight Panel Lightning Component, click Setup, and then select Edit.
-
In the Interface Editor that appears, select the Code View tab.
-
In the
<div class="coveo-tab-section">
section, replace thedata-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 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.
Adding the AttachedToCase result action to a Coveo Insight Panel Lightning Component
-
In Salesforce, access your Lightning Application (e.g., Lightning Service Console, Sales), and then open any record (e.g., Case, Opportunity, Account).
-
At the top right of the Coveo Insight Panel Lightning Component, click Setup, and then select Edit.
-
In the Interface Editor that appears, select the Code View tab.
-
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
-
CoveoV2__PermanentId__c
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.
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:
-
In Salesforce, in Setup, search for and select Object Manager.
-
Under Label, select Attached Result, and then select Fields & Relationships.
-
On the Asset Relationship page, select Fields & Relationships.
-
On the Fields & Relationships page, click New to add a new field.
-
Access your Coveo Insight Panel Lightning Component Code View tab:
-
Click the cogwheel icon in the upper-right corner of your Coveo Insight Panel Lightning Component, and then select Edit.
-
In the interface that opens, select the Code View tab.
-
-
In your page, in a
script
tag, add the following code. Remember to changemyCustomField__C
andmyCustomField2__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 newAttachedResult
object. -
result
- contains additional data about the current result.
-
-
Save your page by selecting Save.
-
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>
When wrapping the component, ensure to 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 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).
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>