2

I have set Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners User Permissions" permission checked true in userinterface. After that i am trying to check whether createddate field is creatable or not But i am getting this value as false. I was hoping that i should get this value as true System.debug(Schema.sObjectType.Account.fields.createdDate.isCreateable());

I am trying to fix a bug in an org(Production) where we are getting iscreatable true for createtaddate and have "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners User Permissions" set as true. But that is not getting reproducable in my org(Scratch).

In workbench also I tested this once. Data> Insert > single record > account But in fields list Createdate was not showing up.

Is there any other setting/permission that we need to enable to make sure we get iscreateable true in apex for createddate.

1 Answer 1

2

After enabling this feature, you need to also enable it on a profile. Assuming you created the scratch org from scratch, you'll have the default System Administrator profile for the user you log in as. Note that the standard System Administrator profile does not have the Set Audit Fields upon Record Creation permission, nor can you edit the default profile to add this permission. Instead, create a new Permission Set, assign that Permission Set the Set Audit Fields upon Record Creation permission (found in the System Permissions section), then assign that Permission Set to your user. If you've set everything up successfully, this Execute Anonymous code will run successfully:

Assert.isTrue(Account.CreatedById.getDescribe().isCreateable());

If you plan on testing this in the feature, you can include your new permission set in your source control, then use the sfdx force user permset assign function to assign your user this profile after org create scratch and project deploy start commands.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .