Play Games

Search This Blog

Thursday, August 18, 2022

Trigger.operationType in salesforce - Salesforce Globe For You

OperationType is a Trigger class context variable which returns an enum of type System.TriggerOperation corresponding to the current operation.

Possible values of the System.TriggerOperation enum are: 

BEFORE_INSERT

BEFORE_UPDATE

BEFORE_DELETE

AFTER_INSERT

AFTER_UPDATE

AFTER_DELETE and 

AFTER_UNDELETE.

Trigger.operationType is used in trigger to determine the type of operation whether it is before insert or before update etc.

Example:

trigger LeadTrigger on Lead ( before Insert ,Before Update , After Insert, After Update) {

    system.debug('Trigger.OperationType :' +Trigger.OperationType);

}

Now when I update any one lead record ,the output is as shown below


It means when the lead record is updated, the lead trigger runs and the Trigger.OperationType tells that the trigger is running for the before update and after update context.

No comments:

Post a Comment