Record API in BeforeDelete
Record
Type: TriggerTypes.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(lookupField) | the old row's parent, loaded by PriorParentQuery, or null |
getRelated(providerName) | rows from a RelatedQuery provider |
isRecordType(recordTypeDeveloperName), isNotRecordType | record type developer name matches / differs |
equals(field, value), doesNotEqual | equal / different; text ignores case |
isIn(field, values), isNotIn | equal to one of the values / to none; 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 |
addErrorOnBeforeDelete gets a TriggerTypes.RejectableDeleteRecord: the same methods, plus addError(error) and addError(field, error).
Records
Type: TriggerTypes.DeleteRecords. RecordsProvider.query gets the whole chunk. finalizeOnBeforeDelete gets 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 |
Rules
- Read-only, but takes errors. Writing to
getOldSObject()throws. A Validator'srecord.addError('…')blocks the delete of that record. - Lookups hold only the Id.
((Contact) record.getOldSObject()).Accountis null. Declare a PriorParentQuery and readgetOldParent(Contact.AccountId). - No merge winner yet.
MasterRecordIdis set only in AfterDelete.
