Record API in AfterDelete
Record
Type: TriggerHandler.DeleteRecord. Predicates read the old row and never throw on null.
| Method | In AfterDelete |
|---|---|
getId() | the record Id |
getOldSObject() | the Trigger.old row, read-only |
getOldParent(relationshipName) | the parent the old row pointed to, loaded by PriorParentQuery, or null |
getRelated(providerName) | rows from a RelatedQuery provider |
isRecordTypeEqual(recordTypeDeveloperName), isRecordTypeNotEqual | record type developer name matches / differs |
equals(field, value), doesNotEqual | equal / different; text ignores case |
contains(field, value), doesNotContain, startsWith, endsWith | text match; case-sensitive |
isNull(field), isNotNull | null / not null |
isEmpty(field), isNotEmpty | null or '' / neither |
isBlank(field), isNotBlank | null, '' or whitespace / none |
isTrue(field), isFalse | true / false |
greaterThan(field, value), greaterThanOrEqualTo, lessThan, lessThanOrEqualTo | number or date comparison; false for null |
Records
Type: TriggerHandler.DeleteRecords, passed to RecordsProvider.query (every record in the chunk), dispatchOnAfterDelete (the qualified records) and finalizeAfterDelete (the qualified records).
| Method | In 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 |
Good to Know
- Ids without rows.
getId()andgetIds()return the deleted Ids, but SOQL no longer finds those rows. Key queries bygetIdsOf(Contact.AccountId). - Lookups hold only the Id.
((Contact) record.getOldSObject()).Accountis null. Declare a PriorParentQuery and readrecord.getOldParent('Account'). - The old row is read-only. Writing a field on
getOldSObject()throws aFinalExceptionthat cannot be caught, not even with ContinueOnError. 0andfalseare values. They are not null, empty or blank.- Record types.
isRecordTypeEqualthrows on an object without record types. An unknown name never matches.
