# Restore Record Ownership and Salesforce Audit Fields

Restoring proper record ownership when restoring historical data can be a complex operation for several reasons:

* By default, Salesforce does not permit an inactive user to be the owner of a record.
* When migrating data from another Salesforce instance, the record owner probably does not exist in the target Salesforce.

While discussing how to manage these issues, this article will also cover a related problem:

* How to restore original Salesforce audit fields like `CreatedDate` and `LastModifiedDate`.

## Problem 1: Make Inactive Users Own Restored Records

By default, not even a Salesforce administrator has the privileges necessary to assign an inactive Salesforce user as the owner of a record. However, any user can be granted this ability by:

* Creating a Permission Set that includes the Salesforce system permission “Update Records with Inactive Owners”.
* Associating the new Permission Set with a Salesforce user account.

CopyStorm/Restore will recognize that its connection to Salesforce has this elevated permission and do the right thing. If you need additional help, see the [Salesforce release notes](http://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_general_audit_fields_inactive_owners.htm#rn_general_audit_fields_inactive_owners) that introduced this feature.

## Problem 2: Control Record Ownership When Users Do Not Exist in the Target Salesforce

This problem most often occurs during a Salesforce migration project. For example, suppose that the Acme company purchased the Dynamo company and the Salesforce team has been told to migrate all data from Dynamo’s Salesforce into the Acme Salesforce.

* The CopyStorm backup of the Dynamo database contains a record owner named “<josiah@dynamo.com>”
* In the Acme Salesforce, “<josiah@dynamo.com>” will be replaced by the new Salesforce user “<josiah@acme.com>”.

During the data migration all records owned by <josiah@dynamo.com> should be transferred to <josiah@acme.com> once all Dynamo data has been migrated to the Acme Salesforce.

The best practice to address this issue is to create a migration mapping for Users in the CopyStorm/Restore Migration Setup tab. By using the Record Mapping Rule Editor on this tab you can explicitly tell CopyStorm/Restore how to map users in the Dynamo database to users in the target Acme Salesforce. For details see these articles:

* [CopyStorm/Restore Migration Tools](https://learn.capstorm.com/copystorm-restore/reference/migration-setup-tab)
* [CopyStorm/Restore Record Mapping Rule Editor](https://learn.capstorm.com/copystorm-restore/reference/migration-setup-tab/migration-record-mapping-tools)

## Problem 3: Restore Salesforce Audit Fields

By default, not even a Salesforce administrator can write to the standard Salesforce audit fields, including:

* `CreatedById`
* `CreatedDate`
* `LastModifiedById`
* `LastModifiedDate`

If you need to restore these fields:

* Create a Permission Set including the Salesforce system permission “Set Audit Fields upon Record Creation”.
* Associate the new Permission Set with a Salesforce user account.

CopyStorm/Restore will recognize that its connection to Salesforce has this elevated permission and do the right thing (e.g. restore audit fields).

## Problem 4: Restore Salesforce Audit Fields In Chatter

In addition to the audit fields detailed in #3 above, restoring the “CreatedBy” and “CreatedDate” fields for Chatter Feeds requires an additional permission.

If you need to restore these fields:

* Create a Permission Set including the Salesforce system permission “Insert System Field Values for Chatter Feeds”.
* Associate the new Permission Set with a Salesforce user account.

CopyStorm/Restore will recognize that its connection to Salesforce has this elevated permission and do the right thing (e.g. restore audit fields).


---

# 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/best-practices/restore-record-ownership-and-salesforce-audit-fields.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.
