Record API in BeforeUpdate
Record
Type: TriggerTypes.UpdateRecord. Predicates read the new row and never throw on null.
| Method | In BeforeUpdate |
|---|---|
getId() | the record Id |
getNewSObject() | the Trigger.new row |
getOldSObject() | the Trigger.old row, read-only |
getNewParent(lookupField) | the parent loaded by ParentQuery, or null |
getOldParent(lookupField) | the old row's parent, loaded by PriorParentQuery, or null |
getRelated(providerName) | rows from a RelatedQuery provider |
put(field, value) | sets a field on the Trigger.new row |
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 |
isChanged(field) | the new value differs from the old one; text ignores case |
isAnyChanged(field1, field2, …), areAllChanged(field1, field2, …) | any / every field changed; 2 to 5 fields or an Iterable<SObjectField> |
isChangedTo(field, expectedValue), isChangedFrom | changed to / from the value |
isChangedToNotNull(field) | changed, and the new value is not null |
isChangedFromTo(field, fromValue, toValue) | the old value is fromValue and the new one is toValue |
addErrorOnBeforeUpdate gets a TriggerTypes.RejectableUpdateRecord: no put, plus addError(error) and addError(field, error).
Records
Type: TriggerTypes.UpdateRecords. RecordsProvider.query gets the whole chunk. finalizeOnBeforeUpdate gets the qualified records.
| Method | In BeforeUpdate |
|---|---|
getIds() | the record Ids |
getIdsOf(field), getOldIdsOf(field) | non-null Ids in a lookup or Id field of the new / old row |
getValuesOf(field), getOldValuesOf(field) | non-null values of a field of the new / old row, as text |
getRecords() | the records, as UpdateRecord |
size() | the number of records |
Pass relationshipName first to read a parent’s field.
Rules
- Text changes ignore case.
'Doe'to'DOE'is not a change.
