We wish to create a scratch org that has the "Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions" setting checked.

Is there a scratch org definition file option available to do this that I'm not seeing. Or failing that is there a programmatic way of setting the setting.

  • Appears to be a duplicate of Metadata for User Interface options which is unanswered. Note, when you do a source:pull after enabling those Setup features, only the NameSettings is retrieved from the User Interface configuration. Github issue was opened in Dec '18 but has been closed without solution. – TSmith Nov 26 '19 at 16:30

What to do

I wrote out instructions in this GitHub repo, including sample files if you need them.

  1. In the source org
    • Run sfdx force:source:retrieve -m Settings:Security
    • Search the retrieved file for enableAuditFieldsInactiveOwner and set the value to true. Save the file.
  2. In a new scratch org
    • Run sfdx force:source:deploy -m Settings:Security immediately after creating the scratch org
    • Run sfdx force:source:push as usual
    • If needed, assign any needed permission sets using sfdx force:user:permset:assign --permsetname [yourauditfieldpermset]

Why should this work?

Basically, you need to enable the set audit fields setting for the org before you attempt to add it to any permission sets or profiles. If you try to enable the setting and push the permission set at the same time, it'll fail silently--the rest of the permission set will go through, but not that piece.

  • Thanks Allison. Will give this a try. Nice thinking. – Stephen Roden Dec 3 '19 at 8:56
  • This just saved me a ton of head scratching! Thank you – Adam Erstelle May 24 '20 at 0:23
  • Life pro tip: you can use packageDirectories to stage push of your security settings and profie/permset. They are now pushed in order they are specified in sfdx-project.json. – dzh Nov 4 '20 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.