# How Do I Restore Attachments?

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

## Step 1: Choose the Account(s) that own Attachment(s)

## Step 2: Uncheck the Restore Type Options “Insert” and “Update”

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.

![](https://2924009365-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5FyPmqVkPxhj2oT8fbgB%2Fuploads%2Fgit-blob-cc16416c71ec33db1dbe120e9a7b2b8d507ca662%2Fdd73eb14-1_Select_Accounts-1024x667.png?alt=media)

## Step 3: Choose the Attachments Related List

This informs CopyStorm/Restore that it should:

* Restore Attachments.
* Only restore Attachments that are directly related to the selected Account(s).

![](https://2924009365-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5FyPmqVkPxhj2oT8fbgB%2Fuploads%2Fgit-blob-ba1df2214d16d656e901a7bebc15b19184d2436a%2F6d7dd821-2_Select_Attachments-1024x668.png?alt=media)

## Step 4: Optionally Add Constraints to Control Which Attachments Are Restored

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.

![](https://2924009365-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5FyPmqVkPxhj2oT8fbgB%2Fuploads%2Fgit-blob-2a3211bb98f02cd89ebbce97076c3269ab80483f%2Fa4d1ff0f-3_Filter_Attachments-1024x645.png?alt=media)

## Step 5: Run the Restore

CopyStorm/Restore will find the Accounts, decide nothing needs to change, and then restore the Attachments.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.capstorm.com/copystorm-restore/frequently-asked-questions/how-do-i-restore-attachments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
