Skip to content

IF_Trigger.BeforeUpdate

Class

apex
global interface IF_Trigger.BeforeUpdate

Known Derived Types: TRG_ExecuteValidationRules, TRG_ExecuteValidationRules.beforeUpdate(List<SObject>,List<SObject>)

Handler contract for the before-update trigger event.


Methods

MethodDescription
global abstract void beforeUpdate(List<SObject> newRecords, List<SObject> oldRecords)Called before modified records are saved, enabling field-level validation, change detection, or in-memory transformations using old and new state.

beforeUpdate

apex
global abstract void beforeUpdate(List<SObject> newRecords, List<SObject> oldRecords)

Called before modified records are saved, enabling field-level validation, change detection, or in-memory transformations using old and new state.

Parameters

ParameterTypeDescription
newRecordsListThe batch of SObjects with their proposed field values.
oldRecordsSObjectThe batch of SObjects with their values prior to the update.

Example

apex
public class TRG_TrackStatusChange extends TRG_Base implements IF_Trigger.BeforeUpdate
{
    public void beforeUpdate(List<SObject> newRecords, List<SObject> oldRecords)
    {
        for(Integer i = 0; i < newRecords.size(); i++)
        {
            if(newRecords[i].get('Status__c') != oldRecords[i].get('Status__c'))
            {
                newRecords[i].put('StatusChangedDate__c', System.now());
            }
        }
    }
}