---
schema_version: "1"
id: 1d045499d0be0545253cfd438852144b15a720e0a5756c9aaaedabdd4ca5155e
title: Load Attachments to Display Object
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/custom_sync_load_attachment_to_displays.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.custom_sync_load_attachment_to_displays.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 7a05134f06435a3753b3bb0aa6b3720c8664640b7c04edc0b4cbec4c120559ee
description: Create and configure a list object to load the attachments. Add the list object to the Display business object and also add a datasource for the attachments.
products:
  - Consumer Goods
release: "264"
---
# Load Attachments to Display Object

Create and configure a list object to load the attachments. Add the list object to the Display business object and also add a datasource for the attachments.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition">
        <colgroup>
          <col>
        </colgroup>
        <tbody>
          <tr class="">
            <td class="slds-cell-wrap" style="vertical-align:top;">
              <p>Available in: Lightning Experience </p>
              <p style="margin-bottom:0;">Available in: <strong>Enterprise</strong> and
                <strong>Unlimited</strong> Editions where Consumer Goods Cloud is enabled
              </p>
            </td>

          </tr>
        </tbody>
      </table> <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d56676e62">User
              Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d56676e62 ">To add and configure list object</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d56676e62 ">
              <p style="margin-bottom:0;">Developer, Customizer</p>
            </td>

          </tr>
        </tbody>
      </table>

1. To create a list object for attachments, in Visual Studio Code based Modeler, run`sf mdl add` and enter these details
    
    ```
     ? Select the resource you want to add. listobject
     ? Specify a name for the listobject: DisplayAttachment
     ? Select the module to which listobject 'DisplayAttachment' should be added. MyDisplay
    ```
2. In DsLoMyDisplayAttachment\_sf.datasource.xml, configure the datasource details as shown in this code snippet.
    
    ```
    <DataSource name="DsLoMyDisplayAttachment" backendSystem="sf" businessObjectClass="LoMyDisplayAttachment" external="false" editableEntity="SF_File" schemaVersion="2.0" readOnly="true">
       <Attributes>
          <Attribute name="attachmentBlobPKey" table="SF_File" column="Id" />
          <Attribute name="pKey" table="SF_FileLink" column="Id" />
          <Attribute name="mediaPath" table="SF_File" column="VersionData" />
          <Attribute name="description" table="SF_File" column="Description" />
          <DerivedAttribute name="type" value="replace(SF_File.PathOnClient, rtrim(SF_File.PathOnClient, replace(SF_File.PathOnClient, '.', '')), '')" />
          <DerivedAttribute name="fileType" value="replace(PathOnClient, rtrim(PathOnClient, replace(PathOnClient, '.', '')), '')" />
          <Attribute name="fileName" table="SF_File" column="PathOnClient" />
       </Attributes>
       <Entities>
          <Entity name="SF_File" alias="" idAttribute="Id" />
          <Entity name="SF_FileLink" alias="">
             <Join Type="inner">
                <SimpleJoin>
                   <Condition leftSideValue="SF_FileLink.FileId" comparator="eq" rightSideType="Attribute" rightSideValue="SF_File.Id" />
                </SimpleJoin>
             </Join>
          </Entity>
       </Entities>
       <QueryCondition><![CDATA[
          SF_FileLink.ParentId = #display#]]>
       </QueryCondition>
       <OrderCriteria>
          <OrderCriterion entity="SF_File" attribute="Relative_Position__c &lt;&gt; 0" direction="DESC" />
          <OrderCriterion entity="SF_File" attribute="Relative_Position__c" direction="ASC" />
       </OrderCriteria>
       <Parameters>
          <Parameter name="display" type="TEXT" />
       </Parameters>
    </DataSource>
    ```
3. To configure the list object, in LiMyDisplayAttachment.listitem.xml, add these simple properties:
    
    The simple properties in this code snippet map specific attributes from the data source to properties in the application, including file keys, media paths, descriptions, types, and file names. Each property is linked to a corresponding data source property for accurate data retrieval.
    
    ```
    <SimpleProperty name="pKey" type="DomPKey" dataSourceProperty="pKey" />
    <SimpleProperty name="attachmentBlobPKey" type="DomPKey" dataSourceProperty="attachmentBlobPKey" />
    <SimpleProperty name="mediaPath" type="DomBlob" dataSourceProperty="mediaPath" blobTable="PrmAttachmentBlob" blobPKeyField="attachmentBlobPKey" />
    <SimpleProperty name="description" type="DomText" dataSourceProperty="description" />
    <SimpleProperty name="type" type="DomFileType" dataSourceProperty="type" />
    <SimpleProperty name="fileName" type="DomFileName" dataSourceProperty="fileName" />
    ```
4. To add the list object to the BoDisplays business object, in BoMyDisplay.businessobject.xml, configure the list object under the ListObject node.
    
    The ListObjects section defines the loAttachment list object that uses the LoMyDisplayAttachment class and maps the pKey from the data source to the display list property. This ensures that the attachments correctly appear in the list.
    
    ```
    <ListObjects>
    	<ListObject name="loAttachment" objectClass="LoMyDisplayAttachment" dataSourceProperty="pKey" listProperty="display" />
    </ListObjects>
    ```
5. Save all the contracts.