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:
- 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.
- 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:
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:
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.