ApexSensei

Drills DML operations

Delete challenge-created records

delete removes records by Id.

Your task

Create two tagged Accounts, delete the whole list in one statement, and prove they moved to the Recycle Bin.

String tag = 'AS-DELETE-' + UserInfo.getUserId() + '-' +
    String.valueOf(Datetime.now().getTime());
List<Account> accounts = new List<Account>{
    new Account(Name = tag + '-A', Description = tag),
    new Account(Name = tag + '-B', Description = tag)
};

Set<Id> createdIds = new Set<Id>();
Integer dmlBefore;

Requirements

  1. delete accounts; should be present
  2. ALL ROWS should be present
  3. Id IN :createdIds should be present
  4. Both owned rows should be printed as Created count: 2
  5. No active owned rows should be printed as Remaining active: 0
  6. Both bin rows should be printed as In recycle bin: 2
  7. One delete statement should be printed as Delete statements: 1

Sign in to open this drill