# How Does CopyStorm Handle Deleted Records?

CopyStorm copies both active and deleted records from Salesforce to the target database by inspecting the Salesforce recycle bin. When a deleted record is discovered its “isDeleted” column is set to true in the target database.

The retention policy for deleted records in the target database is set using the Advanced tab parameter “Delete Older Than”. Available values can range from:

* Remove deleted records immediately.
* Remove deleted records after they have been deleted in Salesforce for 7 days.
* Never remove deleted records.

| Delete Older Than | Description                                                                                                 |
| ----------------- | ----------------------------------------------------------------------------------------------------------- |
| 0                 | Any deleted records copied from Salesforce are immediately deleted from the target database.                |
| 7                 | Deleted records are removed from the target database after they have been deleted in Salesforce for 7 days. |
|                   | A blank value means that deleted records are never removed from the target database.                        |

There are also situations where a record is deleted in Salesforce but is not discovered by CopyStorm. This situation may occur when:

* A user deletes records in Salesforce and empties the recycle bin BEFORE CopyStorm has run.
* A system administrator empties the global recycle bin.
* A Salesforce API program does a hard delete on Salesforce records.
  * A hard delete bypasses the Salesforce recycle bin mechanism.
* Salesforce performs a hard delete.
  * There are a few tables that Salesforce hard deletes by default.

When a Salesforce record is hard-deleted it is usually wise to use the CopyStorm/Medic Fix IsDeleted tool to mark the appropriate records as deleted in the target database. For information on when and how the CopyStorm/Medic tool should be used see [this best practice article](/best-practices/deleted-record-management.md).


---

# 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/frequently-asked-questions/how-does-copystorm-work/how-does-copystorm-handle-deleted-records.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.
