The Silverline BlogExpert Salesforce tips & tricks, articles and musings. Sprinkled with fun.

How-to Migrate Salesforce Attachments

Help & Training

Silverline is always ready to take on Salesforce projects that have never been done before. On a daily basis our team is challenged to solve customer problems that have never been solved before. It’s one of my favorite things about working at Silverline.

Silverline recently had a client that wanted to migrate their Salesforce Attachments from one Org to another. This posed a challenge for us since there are no ETL tools that allow us to move them easily and efficiently while also preserving which Parent record the Attachment belongs to. There were two key issues we faced:

  1. Using the query() API call (which most ETL tools use) only allows one complete (by complete I mean with the Body field included) Attachment record to be exported at a time.
  1. Performing external Id lookups on polymorphic fields (in this case the ParentId).

After doing a little research (see Attachment Documentation), we were able to leverage the retrieve() API call from Salesforce which gave us the ability to grab more than one complete Attachment record at time. This cut the amount of API calls needed by ten fold.

The last piece of the puzzle was how to perform an external Id lookup on a polymorphic field. We leveraged two tools to figure this out:

  1. Workbench
  2. Runscope

Workbench’s Smart Lookup feature allows external Id lookups on polymorphic fields. Knowing this we sniffed the traffic sent by Workbench using Runscope and discovered how it was done. Here is the key part of the message:

<Parent>
<type>Account</type>
<External_Id__c>001E0000016s7okIAA</External_Id__c>
</Parent>

Once we had the complete picture of how to get around these limitations, we created an application written in Node.js to automate the entire process. Something which could have taken weeks, was completed in a matter of hours. The source code can be found on Github.

Want to learn more about Silverline’s tips & tricks for using and configuring Salesforce? Subscribe to our blog to ensure you never miss a post.

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz
Need a custom solution? We can help. Let's Chat