EONE BLOG

Tech Tuesday: SalesForce Notes and Attachments


SalesForce allows files to be attached to records. These files are stored as Base64 encoded data in the ‘Content Version’ object. SmartConnect can be used to encode these files and upload them to SalesForce. Once the attachment is imported, we will need to use the ‘Content Document Link’ object to link the document to the relevant records in Salesforce. In today’s article we go over the steps to upload a file to SalesForce and link it to a record. In my example I will be attaching a PDF to an existing Account. At the bottom of the article is a download link for the maps used in this example.

Create Content Version

Create a map with the following information in the source. You can use a multi-data source if needed to retrieve all the necessary information.

  • Account Id in SalesForce
  • File path of the PDF file
  • Title of the document

We will select ‘Content Document Version’ as the destination object. We will map the SalesForce Id to the Description of the ‘Content Document’. This will give us a unique field to use when we link the Content Document to the Account. We will group our map on the Id field that we mapped to Description, because this is our unique identifier for the Content Document.

Content Document (Version) Mapping


 

The PDF file can be easily encoded with a calculated column. Here is a sample script for the calculated column.

return System.Convert.ToBase64String(File.ReadAllBytes(_FILE))

 

Link the Content Document

We will create a second map to link the imported Content Document to the Account record. For my example I used the same data source for my child map and set it as a post map task to link all the newly imported content documents. This map will have a destination object of ‘Content Document Link’.

We will need to map the ContentDocumentID which can be populated using an entity lookup using the Description field on Content Document.  The LinkedEntityId is the Id of the Account record I want linked to this document.

ContentDocumentId


 

Content Document Link Mapping

Updating an Attachment

There are times when we will need to update a document. SalesForce handles this by allowing for multiple versions of the same document. The only thing that will need to change in our existing map is the Title. If the Title is different, SalesForce will add a new version on the existing document.

You will not need to run the Document Link map on an update, because the existing link is still being used regardless of version. If you try to update a Document Link you will receive errors that you cannot edit the ContentDocumentId and LinkedEntityId.

 

Conclusion

Keep in mind that SalesForce is a hosted environment so it is not encouraged to store large documents this way unless absolutely necessary. The Salesfoce maximum file size that can be upload via the SOAP API is 50 MB. When a document is uploaded or downloaded via the API, it is converted to base64 and stored in VersionData. This conversion increases the document size by approximately 37%. Account for the base64 conversion increase so that the file you plan to upload is less than 50 MB after conversion.

SF Attachment Maps

 

Leave a Comment




RECENT POSTS


SmartConnect Office Hours for Friday, June 21st, 2019
Free Samples (ie Sample Data!) with Popdock
2019 Summer Webinar Schedule
SmartConnect Bootcamp in Raleigh, NC – Don’t Miss It!
Tech Tuesday: Issues to be aware of when creating maps that use text ODBC drivers

POPULAR POSTS


2016 SmartConnect Integration Bootcamps
Tech Tues: Automatically refreshing Pivot Tables in Excel Refreshable Reports
Happy Thanksgiving from the eOne team!
New Releases of Extender and SmartList Builder
2017 SmartConnect Integration Bootcamps

CATEGORIES

ARCHIVES

open all | close all

TAGS

CRM Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News eOne Spotlight ERP Events Excel Excel Report Builder Extender Extender Enterprise Flexicoder GP GPUG integration integration manager Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Office Relationships partners Popdock release Reporting SalesForce SalesForce.com scripting SmartConnect SmartConnect.com SmartConnect Office Hours SmartList SmartList Builder SmartList Designer SmartView SQL Support Tech Tuesday Templates training Zendesk

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.