function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KaityKaity 

When Trigger.IsInsert and Trigger.IsUpdate fires?

When Trigger.IsInsert and Trigger.IsUpdate fires?

 

Is it 'before' event or 'after' event or both?

souvik9086souvik9086

For both

 

When you use two events (after insert,after update)

 

Then for isInsert() it will execute when it is called on insertion and same as update.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

 

Sagarika RoutSagarika Rout

"Trigger.IsInsert"  and  "Trigger.IsUpdate" are both trigger Context Variables and These variables are contained in theSystem.Triggerclass.

 

"Trigger.IsInsert " returns true  if this trigger was fired due to an insert operation, from the Salesforce user interface, Apex, or the API.

"Trigger.IsUpdate" returns true if  this trigger was fired due to an update operation, from the Salesforce user interface, Apex, or the API.

These variables are applicalbe for both "before" and "after" event as well.

 

For better understanding please go through below link

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables.htm

 

Best

Sagarika Rout

Associate Salesforce Consultant

Jeremiah BaylesJeremiah Bayles
Is it possible to combine them into one condition?
Ie: IF (Trigger.isInsert OR Trigger.isUpdate) {}

Or something like 
IF (Trigger.isBefore AND Trigger.isInsert) {}

?
 
Peter Wells 4Peter Wells 4
Yes, it is possible, and very useful at times, to combine them into a single logical evaluation.