Skip to main content
[ This file is autogenerated from apexdoc ]

abstract AqObj

Trigger framework and base class for all standard and custom object classes.

Group apex/core

Properties​

protected TriggerRecords → List<SObject>​

Returns relevant set of records for processing in the trigger This includes management of errored records within the same instantiation, so that error records aren't presented to methods for downstream processing.


Methods​

Public methods​

public virtual void onTrigger()​

Entry method called from the trigger itself Extend your SObject trigger handler class from AqObj (e.g. AccountObj). Create the corresponding .trigger class and call onTrigger() method. All the protected triggers methods mentioned below gets TriggerRecords list as a parameter. Account.trigger:

Example​
trigger Account on Account (before insert, before update, after update) {
new AccountObj().onTrigger();
}
//
// In your handler, override required protected trigger method (`preValidateDelete()` |
// `preValidate()` | `initialize()` | `calculate()` | `validate()` |
// `postInsertUpsertDelete()` | `postInsert()` | `postUpsert()` | `postUpdate()` | `postDelete()`)
// and put your trigger logic inside, e.g.:
//
protected override void postUpdate(List<SObject> records) {
this.updateAccountFields(records);
}

Protected triggers methods​

protected virtual void preValidate(List<sObject> records)​

Validate before any calculation is done -- to validate any values that must be correct before any calculation

protected virtual void preValidateDelete(List<sObject> records)​

Do any pre-delete validation to potentially prevent deletion

protected virtual void initialize(List<sObject> records)​

Initialize values on a new record

protected virtual void calculate(List<sObject> records)​

Calculate values on a new or updated record

protected virtual void validate(List<sObject> records)​

Validate all values after calculations have taken place

protected virtual void postInsert(List<sObject> records)​

Do any processing that should happen only after insert (but not after update or delete)

protected virtual void postUpdate(List<sObject> records)​

Do any processing that should happen only after update (but not after insert or delete)

protected virtual void postUpsert(List<sObject> records)​

Do any processing that should happen after insert OR update (but not after delete)

protected virtual void postDelete(List<sObject> records)​

Do any processing that should happen after delete

protected virtual void postInsertUpsertDelete(List<sObject> records)​

Do any processing that should happen after insert, update, or delete


Protected auxiliary methods​

protected void addError(sObject record, sObjectField field, String errorString)​

Add error to a record

protected Boolean isInsert()​
protected Boolean isUpdate()​
protected Boolean isDelete()​
protected Boolean isUndelete()​
protected List<sObject> oldRecords()​

Return old records

protected sObject oldRecord(sObject record)​

Return old record

protected object oldValue(sObject record, sObjectField field)​

Return old field value

protected Map<Id,sObject> getOldMap()​

Return old records


Protected validation methods​

protected void require(sObject record, sObjectField field, Boolean condition, String errorMessage)​

Works like an assert to add error if condition is not met

protected void requireFields(sObject record, Set<sObjectField> fields)​

Required the record to have values set on all specified fields

protected void requireField(sObject record, sObjectField field)​

Required the record to have values set on the specified field

protected void requireTogether(sObject record, Set<SObjectField> fields)​

If any are not-null, then all must be not-null

protected void validateString(sObject record, sObjectField field, String dataType, Boolean required, Integer maxLength)​

Validate a string against specified type

protected void validateString(sObject record, sObjectField field, String dataType, Boolean required)​

Validate a string against specified type

protected void validateString(sObject record, sObjectField field, String dataType)​

Validate a string against specified type

protected void validatePattern(sObject record, sObjectField field, Boolean required, String regEx, String patternLabel)​

Validate a string to meet specified pattern

protected void validateInteger(sObject record, sObjectField field, Boolean required, Integer min, Integer max)​

Validate an integer for range

protected Boolean isChangedField(sObject record, sObjectField field)​

Change detection Returns true if field is changed in this trigger context

protected Boolean isChangedAnyField(sObject record, Set<sObjectField> fields)​

Returns true if any specified field is changed in this trigger context

protected Boolean isChangedFieldFrom(sObject record, sObjectField field, object fromValue)​

Returns true if field changed from specified value to some other value

protected Boolean isChangedFieldTo(sObject record, sObjectField field, object toValue)​

Returns true if field changed to specified value

protected Boolean isChangedFieldToNonNull(sObject record, sObjectField field)​

Returns true if field changed and to a non-null value