Record API in AfterUpdate
Record
Type: TriggerTypes.UpdateRecord. Predicates read the new row and never throw on null.
| Method | In AfterUpdate |
|---|---|
getId() | the record Id |
getNewSObject() | the Trigger.new row, read-only |
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) | compiles, but throws System.FinalException: the row is read-only |
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 |
Records
Type: TriggerTypes.UpdateRecords. RecordsProvider.query gets the whole chunk. dispatchOnAfterUpdate and finalizeOnAfterUpdate get the qualified records.
| Method | In AfterUpdate |
|---|---|
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
- Parents are not on the row.
getNewSObject().Accountis null. ReadgetNewParentorgetOldParent.
