Record API in BeforeDelete
Record
Type: TriggerHandler.DeleteRecord. Predicates read the old row and never throw on null.
| Method | In BeforeDelete |
|---|---|
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) and finalizeBeforeDelete (the qualified records).
| Method | In BeforeDelete |
|---|---|
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
- Only the old row. There is no
put,getNewSObjectorgetNewParent. - Read-only, but takes errors. Writing to
getOldSObject()throws.getOldSObject().addError('…')blocks the delete of that record. - Lookups hold only the Id.
((Contact) record.getOldSObject()).Accountis null. Declare a PriorParentQuery and readgetOldParent('Account'). - No merge winner yet.
MasterRecordIdis set only in AfterDelete.
