Record API in AfterUpdate
Record
Type: TriggerHandler.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(relationshipName) | the parent loaded by ParentQuery, or null |
getOldParent(relationshipName) | the parent the old row pointed to, 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 |
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 |
isChanged(field) | the new value differs from the old one |
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 |
isChangedFromTo(field, fromValue, toValue) | the old value is fromValue and the new one is toValue |
Records
Type: TriggerHandler.UpdateRecords, passed to RecordsProvider.query (every record in the chunk), dispatchOnAfterUpdate (the qualified records) and finalizeAfterUpdate (the qualified records).
| Method | In AfterUpdate |
|---|---|
getIds() | the record Ids |
getIdsOf(field) | non-null Ids in a lookup or Id field of the new row |
getIdsOf(relationshipName, field) | Ids in a field of a parent loaded by ParentQuery |
getOldIdsOf(field) | non-null Ids in a lookup or Id field of the old row |
getOldIdsOf(relationshipName, field) | Ids in a field of a parent loaded by PriorParentQuery |
getValuesOf(field) | non-null values of a field of the new row, as text |
getValuesOf(relationshipName, field) | values of a field of a parent loaded by ParentQuery, as text |
getOldValuesOf(field) | non-null values of a field of the old row, as text |
getOldValuesOf(relationshipName, field) | values of a field of a parent loaded by PriorParentQuery, as text |
getRecords() | the records, as UpdateRecord |
size() | the number of records |
Good to Know
- Both rows are read-only. Any write throws
System.FinalException, which nocatchstops. - Parents are not on the row.
getNewSObject().Accountis null. ReadgetNewParentorgetOldParent. getRecords()is not a copy. Removing items also removes them from what the Finalizer receives.
