Summary:
There are times in which you will want to Override the "Created Date" or "Created By" field in Salesforce.
OOTB, Salesforce does not allow you to override the Created Date field as it is a special field and locked down
When you enable the system permission “Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions” what this allows you to do is:
For CreatedDate and CreatedBy
Allows you to manipulate these field on a New Record from a Flow (Create Record element) or from a Data Upload
It doesn't allow you to change these fields from the UI - must be done via an API action
Step 1: Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions
There is a special setting under Setup > User Interface that allows you to override these fields when a record is being created.
The permission is called Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions
When this setting is enabled as denoted by the Checkmark above, provides you the ability to assign out this permission via a Permission Set to allow for the override to happen on Created Date or Created By on New Records.
Step 2: Assign this permission via a Permission set to a set of users
Go to Setup > Permission Sets
Click New
Give it a title such as “Audit Fields Permission” and assign it to the Salesforce user License
Next in the newly created Permission Set, search for the permission that you just enabled
Add that Permission to the Permission Set
Next you will want to assign users to that Permission set
Go to Managed Assignments
Add the users you want to add to the Permission Set
Simultaneously, if you don't want to add specific users but to a profile then you would go to a Permission Set Group and add the permission set to the Permission Set Group
Now you will be able to Override the CreatedBy and CreatedDate field and Assign Records to an Inactive Owner.
Use Cases 1: Importing new records into Salesforce with an override on the CreatedDate
As mentioned, this permission you have enabled only works on newly created records. Therefore, if you get a list of records that you want to modify the CreatedDate in the sheet you are importing you must follow the Salesforce syntax for CreatedDate which looks like this:
2022-03-15T14:40:14.000+0000 |
To create this syntax:
Have the created date field appear as YYYY-MM-DD in one column
In another column paste in the time field
Then in a third column use the concat function =CONCAT(C2 (date), D2(Time))
The 3rd column is the one you will use for CreatedDate
The same use case can apply to the CreatedBy field, on the file you are uploading, add a column on who was the creator by using the 18 digit (ownerId). To get this 18 Digit Character, deploy the following Workflow thats highlighted in this Help Center Article.
Use Case 2: Creating a Record in Salesforce from a Flow to manipulate the CreatedBy or CreatedDate field
Once you have granted yourself with the permission above, you can use a flow to override the CreatedDate Field or CreatedBy field in a Create Record step.
In this example, the CreatedById is now exposed so we can now assign out who the creator of this opportunity should be.