Fix a mixed DML error
A User with a role cannot share a transaction with Account.
Your task
Fix onboard so the Account is created now and the User is created in a separate transaction.
public class AS_2CA250FAD60D_Onboarding {
public static void onboard(String accountName, String lastName) {
User nextUser = AS_2CA250FAD60D_UserBuilder.build(lastName);
insert new Account(Name = accountName);
insert nextUser;
}
}Requirements
- createsTheAccountNow should pass
- createsTheUserAfterTheTransaction should pass
- defersTheUserInsert should pass
- queuesOneFutureCall should pass