Dealing with attachments

In SalesForce you can store various types of files attached to your objects. Keep in mind that attachments can't exist on their own, they must always be linked to an object (ex: a contact, an event).

Attachments can be up to 25MB each, for a file attached to a Salesforce Knowledge & Documents tab, the limit is 5MB. The maximum email attachment size is 10 MB.

Importing an Attachment

1.Compress all of the attachments into a .zip file

Build a .zip file that contains all of the files you want to upload.

2. Make sure that the related objects exist in SalesForce and get their IDs

Each attachment must be linked to an object ( a contact, event, etc) that already exists in SalesForce before you can import it.

Each one of these objects has a unique ID, a number that identifies it regardless if it shares a name with another. 

To obtain these IDs you can perform an Export, making sure that you request for the ID field.

3. Build a CSV file with the required info.

This CSV needs to include three required fields:

  • File Name: The name of the file as you want it to exist in SalesForce
  • Parent ID :  The ID of the parent element that each attachment will be linked to
  • Body: The file path of the file as it exists in the .zip file you built in the previous step

When opened as a spreadsheet, your csv file should resemble this table:

File Name Parent ID Body
Attachment1newName.png 00000001 Attachment1.png
Attachment2newName.png 00000002 Attachment2.png

4. Create a new Import Task

  • Click New Task on the top menu bar
  • Select Import

5. Configure Connection and Object

  • Select your connection from the dropdown menu.
  • Select your operation type: InsertUpsert or Update.
  • Select Attachment as the object you wish to import data into

 

6. Select both the .csv and the .zip that you created

You will be prompted to select two files to upload. One is the .zip file that contains the actual attachments, the other is the .csv that contains a reference to each.

 

You can select these files from your disk or also from other repositories such as DropBox, Box and FTP/SFTP servers.

7. Proceed with the regular Import steps

Move on to the following steps of creating an import task: Mapping your fields and Running the task.

Exporting an Attachment

All you need to do is to export as usual, just make sure to select the "attachment" object in the fist step.

 

 

Select the field "body" in the second step (all other fields are information about the attachment, but the body is the attachment itself.

 

Once the task runs, you can download the attachments by clicking on the task manager on the link next to the export task. This will download all of the attachments compressed into a .zip file. 

 

 

Deleting an Attachment

Attachments are deleted just like any other object. All you need to do is upload a .csv file with the IDs of the attachments you wish to delete.

Have more questions? Submit a request

Comments

Article is closed for comments.