I have created a trigger on the Account object that is validated only if the records are being created by an non-admin account.
In order to test this functionality I would have to set the
createdbyidfield in the test class, but when trying to do this I get the error:
Field is not writeable: Account.CreatedById
I know that for the
CreatedDate field, even though normally is not writable it can be changed in a test environment.
Is the same functionality available for
If not, are there any other workarounds that would allow me to test this scenario?
Any help would be much appreciated!