Skip to content

Record API in AfterDelete ​

Record ​

Type: TriggerTypes.DeleteRecord. Predicates read the old row and never throw on null.

MethodIn AfterDelete
getId()the record Id
getOldSObject()the Trigger.old row, read-only
getOldParent(lookupField)the old row's parent, loaded by PriorParentQuery, or null
getRelated(providerName)rows from a RelatedQuery provider
isRecordType(recordTypeDeveloperName), isNotRecordTyperecord type developer name matches / differs
equals(field, value), doesNotEqualequal / different; text ignores case
isIn(field, values), isNotInequal to one of the values / to none; text ignores case
contains(field, value), doesNotContain, startsWith, endsWithtext match; case-sensitive
isNull(field), isNotNullnull / not null
isEmpty(field), isNotEmptynull or '' / neither
isBlank(field), isNotBlanknull, '' or whitespace / none
isTrue(field), isFalsetrue / false
greaterThan(field, value), greaterThanOrEqualTo, lessThan, lessThanOrEqualTonumber or date comparison; false for null

Records ​

Type: TriggerTypes.DeleteRecords. RecordsProvider.query gets the whole chunk. dispatchOnAfterDelete and finalizeOnAfterDelete get the qualified records.

MethodIn AfterDelete
getIds()the record Ids
getIdsOf(field)non-null Ids in a lookup or Id field
getIdsOf(relationshipName, field)Ids in a field of a parent loaded by PriorParentQuery
getValuesOf(field)non-null values of a field, as text
getValuesOf(relationshipName, field)values of a field of a parent loaded by PriorParentQuery, as text
getRecords()the records, as DeleteRecord
size()the number of records

Rules ​

  • Ids without rows. getId() and getIds() return the deleted Ids, but SOQL no longer finds those rows. Key queries by getIdsOf(Contact.AccountId).
  • Lookups hold only the Id. ((Contact) record.getOldSObject()).Account is null. Declare a PriorParentQuery and read record.getOldParent(Contact.AccountId).
  • 0 and false are values. They are not null, empty or blank.