ApexSensei

Drills Debugging

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

  1. createsTheAccountNow should pass
  2. createsTheUserAfterTheTransaction should pass
  3. defersTheUserInsert should pass
  4. queuesOneFutureCall should pass

Sign in to open this drill