IF_Trigger.BeforeUpdate
Class
apex
global interface IF_Trigger.BeforeUpdateKnown Derived Types: TRG_ExecuteValidationRules, TRG_ExecuteValidationRules.beforeUpdate(List<SObject>,List<SObject>)
Handler contract for the before-update trigger event.
Since: 1.0
Methods
| Method | Description |
|---|---|
| global abstract void beforeUpdate(List<List<SObject> oldRecords) | Called before modified records are saved, enabling field-level validation, change detection, or in-memory transformations using old and new state. |
Method Details
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:
newRecords(List) - The batch of SObjects with their proposed field values.oldRecords(SObject) - The batch of SObjects with their values prior to the update.
Since: 1.0
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());
}
}
}
}