ApexSensei

Drills Triggers

Block deleting Accounts with open deals

A delete trigger has no Trigger.new; the records are in Trigger.old and keyed by Id in Trigger.oldMap.

Your task

Finish the trigger so an Account with an open Opportunity cannot be deleted, using one query.

trigger AS_34784F4B6BCF_AccountDelete on Account (before delete) {
    Set<Id> accountsWithOpenDeals = new Set<Id>();
    for (Account account : Trigger.old) {
    }
}

Requirements

  1. blocksAccountWithOpenDeal should pass
  2. deletesAccountsWithoutOpenDeals should pass
  3. addsOneErrorPerAccount should pass
  4. blocksTheRightAccountsInBulk should pass
  5. keepsQueryCostFlatFromTwoToTwoHundred should pass

Sign in to open this drill