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
madhumadhu 

trigget update also firing in insert

in trigger if i insert a record both insert and update is firing why it is?????
vishal negandhi 7vishal negandhi 7
This is impossible unless you have made a mistake in the code. Unless you share the code, no one here can help you with this.
ManojjenaManojjena
Hi Madhu,

Please is it possible to post your trigger code here .

May be you have kept the event both insert and update ,So that when you will insert record in your object some other code will update your record ,So that your trigger is executing .

Please let me know if it helps .

Thanks 
Manoj
Jitendra RawatJitendra Rawat
Hi Madhu,

Only possibility for this is that there are a workflow on the object which have field update workflow action. When the record is inserting and match the entry cirteria of the workflow then it will update the field of the record. This will couse re-fire the the after update trigger again one time.
You can check the execution process of salesforce in this link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm)which will help you.

If this answer help you then please select this as best answer.

Thanks
Amit Chaudhary 8Amit Chaudhary 8
I hope you are using trigger like below. That is why all code is executing in insert and update also
 
Trigger AccontTrigger on Account( before insert,before update)
{
......
}

Please create your trigger like below :-
 
Trigger AccontTrigger on Account( before insert,before update)
{

 if(Trigger.isInsert)
 { 
  ................ Add insert logic here
 }
else if (Trigger.isUpdate)
{
 .......... Add all update trigger logic heere
}

}

you can see trigger framework in below blog. I hope that will help you
http://amitsalesforce.blogspot.in/2015/06/trigger-best-practices-sample-trigger.html

Please mark this as solution if this will help you

Thanks
Amit Chaudhary