All Collections
Gearset for data sandbox seeding
Can I preserve the source record ID when deploying new data?
Can I preserve the source record ID when deploying new data?
Valerio Chang avatar
Written by Valerio Chang
Updated over a week ago

As we understand the Salesforce API, we cannot control the record ID of a new record being created in a target org to match a source org.

None of the tools we come across have been able to do this.

When data is deployed from a sandbox to production org, Salesforce will assign each record a new ID.

For this reason, we strongly advise against linking data records by ID in a source org. It is not best practice to hard code static IDs in tests or workflows. It's better to use the Name field or other unique fields.

As documented by Salesforce:

Every record, regardless of entity type, has a globally unique identification value in its ID field which is generated at the time of record creation. That Record ID value will never change, even if the record is deleted and then undeleted.

So the only way the record ID would be the same is if you restored within the Salesforce org from the recycle bin.

When Salesforce record IDs are the same

During a full or partial sandbox refresh, record IDs are preserved from the production org to the sandbox org. Record IDs are also preserved when refreshing a sandbox for standard objects, or when a sandbox is cloned.

Even when record IDs are preserved, Salesforce still breaks the association of the records between different orgs. As the orgs are not connected, changes in one org after the refresh will not be reflected in the other.


Did this answer your question?