Before restoring Attachments with CopyStorm/Restore it may be useful to understand how Attachments are handled by Salesforce and how they are different from most tables. When a table in Salesforce contains a reference to another table is is almost always possible to know the type of table being referenced. For example, the Contact.AccountId field will always reference a record in the Account table. However, in the Attachment table, a number of reference fields are not so specific (e.g. Attachment.parentId) and can reference many built-in and all custom tables in Salesforce. This type of table is also known as “polymorphic” because they can “morph” into being a child of almost any type of table.
When restoring polymorphic table records, the best way to find the records is almost always to start with their parent table.
If this is a bit confusing, here is a specific example for restoring Attachments related to Accounts:
This informs CopyStorm/Restore to avoid inserting or updating Account records. The application will still find candidate records — this is necessary because the Attachments to be restored reference Accounts.
This informs CopyStorm/Restore that it should:
- Restore Attachments.
- Only restore Attachments that are directly related to the selected Account(s).
To restore a particular Attachment, constrain the search using a filter. This is rarely necessary due to Attachments being largely static once attached to an object.
CopyStorm/Restore will find the Accounts, decide nothing needs to change, and then restore the Attachments.