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
Raghu RamanujamRaghu Ramanujam 

Understanding Apex Triggers

Hello Gurus,
Need some understanding of how triggers work.

Wrote this Code (SFDC99)
Trigger

When I did a Debug, I got this ..
Debug
Trigger Executed Twice ???
Tried RunOnce..
RunOnce
And Got this ..

Debug1
Only Before Trigger is Executed .. Very Confused ..
Can someone please explain how triggers work ??

Thanks,
Raghu
Raghu RamanujamRaghu Ramanujam
Debug Log is after Updating a Lead Record ..
cloudstreamercloudstreamer
Is there a workflow on the Lead object with does a field update on Lead when the Lead record is updated? Probably the workflow field update is triggering the before and after update triggers once again 
sandeep@Salesforcesandeep@Salesforce
Trigger works in below manner: 
1. First before trigger gets fired
2. then after triggers
3. IF there is any field update occurs then 
4. again first before and then after trigger ( of update event only) get fired.

Thanks
Sandeep Singhal
Raghu RamanujamRaghu Ramanujam
Thanks @ CloudStreamer, @Sandeep.

In this scenario, how to prevent recursive triggers.

If I use a static variable, only Before Triggers execute ?

I want Before and After Triggers fire just one time ??

Thanks,
Raghu