--- title: Add the Attached Results component slug: '3102' canonical_url: https://docs.coveo.com/en/3102/ collection: coveo-for-salesforce source_format: adoc --- # 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](#attach-to-case-result-action) in the [Coveo Insight Panel Lightning Component](https://docs.coveo.com/en/1028/). Coveo for Salesforce currently offers two distinct options to integrate the Attached Results component into a Salesforce record page: * Using the [Attached Results Lightning component](#attached-results-lightning-component-recommended) (recommended) * Using the [Attached Results tab](#attached-results-tab) > **Important** > > * As of the [March 2020 maintenance release (v3.48)](https://docs.coveo.com/en/1280#march-2020-maintenance-release-v348), the Attached Results and Case Attached Results [custom objects](https://trailhead.salesforce.com/en/content/learn/modules/data_modeling/objects_intro) support [Salesforce Field-Level Security](https://help.salesforce.com/articleView?id=admin_fls.htm&type=5). > > 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](https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/users_profiles_fls.htm)). > > * As of the [November 2021 release of Coveo for Salesforce (v4.20)](https://docs.coveo.com/en/3236#november-2021-release-v4-20), the [Attached Result custom object](https://docs.coveo.com/en/3102#attached-result-custom-object) also stores the value of the `CoveoV2\__PermanentId__c` item field (see [About the PermanentId field](https://docs.coveo.com/en/1913/)). > Going forward, this item field will be used instead of the `CoveoV2\__UriHash__c` when storing the attach actions performed by an agent. > > To avoid field access errors, [set field permissions](https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/users_profiles_fls.htm) on the `CoveoV2\__PermanentId__c` item field. ## Attached Results Lightning component (recommended) 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](https://docs.coveo.com/en/1342/) name. This is particularly useful to take advantage of [Coveo Machine Learning (Coveo ML)](https://docs.coveo.com/en/188/) and to improve [Coveo Analytics](https://docs.coveo.com/en/182/) reporting. ![Attached Results component | Coveo for Salesforce](https://docs.coveo.com/en/assets/images/coveo-for-salesforce/results-component.png) ### Add the Attached Results Lightning component to a record page . [Integrate the Coveo Insight Panel Lightning Component](https://docs.coveo.com/en/1028/) in your record page. . Access your Lightning Application (for example, the Lightning Service Console), and then open any record (for example, a case). . In the upper-right corner of the page, click **Setup** (the gear icon), and then select **Edit Page**. . 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](#add-the-attach-to-case-result-action-to-a-coveo-insight-panel-lightning-component) 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](https://docs.coveo.com/en/assets/images/coveo-for-salesforce/results-tab.png) > **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. . [Integrate the Coveo Insight Panel Lightning Component](https://docs.coveo.com/en/1028/) in your record page. . Access your Lightning Application (for example, the Lightning Service Console), and then open any record (for example, a case). . In the upper-right corner 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 `
` section, add the following: ```xml ``` Now that you've added the Attached Results tab, [add the Attach to Case result action](#add-the-attach-to-case-result-action-to-a-coveo-insight-panel-lightning-component) 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. . Access your Lightning Application (for example, the Lightning Service Console), and then open any record (for example, a case). . In the upper-right corner 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 `
` section, replace the `data-caption` value with the name you want to use, for example: ```xml ``` Where you replace `` 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, 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](https://docs.coveo.com/en/assets/images/coveo-for-salesforce/attach-to-case-result-action.png) ### Add the Attach to case result action to a Coveo Insight Panel Lightning Component . Access your Lightning Application (for example, the Lightning Service Console), and then open any record (for example, a case). . In the upper-right corner 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 `
` section, add the following string if it isn't already included: ```xml
``` ## Attached Result custom object When an agent clicks the [Attach to case result action](#attach-to-case-result-action) to attach a search result to a Salesforce object, the Coveo Attached Result [custom object](https://trailhead.salesforce.com/en/content/learn/modules/data_modeling/objects_intro) stores information on the attach actions performed by the agent. This custom object is useful when you want to [report](https://help.salesforce.com/articleView?id=rd_reports_overview.htm&type=5) 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** > > To avoid field access errors, [set field permissions](https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/users_profiles_fls.htm) on the `CoveoV2\__PermanentId__c` item field after installing [Coveo for Salesforce (v4.20)](https://docs.coveo.com/en/3236#november-2021-release-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, create new fields in the Attached Result custom object: . In Salesforce **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. . [Create your new field](https://help.salesforce.com/articleView?id=adding_fields.htm&type=5). . Access the **Code View** tab in your **Coveo Insight Panel Lightning Component**: .. Click the gear 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 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. ```javascript $("#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. . Click **Save**. . Ensure that your custom field is displayed in your console **Case Layout** (see [Edit Page Layouts for Standard Objects](https://help.salesforce.com/articleView?id=accessing_layout_standard.htm&type=0&language=en_US)). ## 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](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_create_devconsole.htm)). ```xml ``` > **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](https://github.com/coveo/search-ui), the [jQuery](https://jquery.com/) (latest 3.x.x version) and [Underscore.js](http://underscorejs.org/) (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](#title) * [name](#name) * [searchHub](#searchhub) * [debug](#debug) #### `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 Analytics](https://docs.coveo.com/en/182/), 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](https://coveo.github.io/search-ui/components/tab.html)). ### Methods This component doesn't provide any methods. ### Usage You must [add this component to your Coveo Insight Panel Lightning Component](#add-the-attached-results-tab-in-a-coveo-insight-panel-lightning-component). ```xml ``` ## AttachToCase result action reference > **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](https://docs.coveo.com/en/1640/)). ### Options This component offers the following options: * [displayText](#displaytext) * [readonly](#readonly) #### `displayText` Specifies if the component should include the `Attach/Detach` text. The default value is `true`. ```xml
``` #### `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`. ```xml
``` ### Methods This component provides the following methods: * [attach](#attach) * [detach](#detach) * [isAttached](#isattached) #### `attach` Attaches the result to the current Case. ```javascript $('#myAttachToCase').coveo('attach') ``` #### `detach` Detaches the result from the current Case. ```javascript $('#myAttachToCase').coveo('detach') ``` #### `isAttached` Returns whether the result is attached. ```javascript $('#myAttachToCase').coveo('isAttached') ``` ### Usage ```html
```