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
Pavan VadlamudiPavan Vadlamudi 

after update trigger is not firing after workflow field update action.

I have the scenario that when ever stage is updated with closed won we are creating another open opportunity.
This update is manula update and working fine.
For same scenario we have workflow to update the record with closed won in this case after update trigger is not working fien.
could anyone suggest me the cause.its kind of priority to me now.
Best Answer chosen by Pavan Vadlamudi
Paul S.Paul S.
Sorry - I suppose I should have asked for the code that includes the recursive check, which I now assume would be the OpportunityLogicHandle class.  Either way, you could change the recursive check statement to also include logic that would check to see if it was the stage that was updated.  If it was, allow the logic to proceed.  Something like:
if(recursive = false || opp.Stage != oldOpp.Stage){
 //code
}

All Answers

Paul S.Paul S.
Is the workflow being triggered by an update to the opportunity record?  If so, do you have some type of recursive check in your code?
Pavan VadlamudiPavan Vadlamudi
yes Paul workflow firing on update of the opportunity record.Yes i have recusive check on code as well.Please suggest me if anything that can be give the solution.
Paul S.Paul S.
That’s it for sure, then. You recursive check is preventing the trigger from running again when the workflow again updates the record. Can you post the trigger code?
Pavan VadlamudiPavan Vadlamudi
Here is my code...
trigger OpportunityTrigger on Opportunity (after insert,before delete,after update,before insert,before update) {
    //Creating New and Old Cpp Opportunity List for after update
    List<Opportunity> oldCppopp = new List<Opportunity>();
    List<Opportunity> newCppopp = new List<Opportunity>();
   
    //Creating New and Old Maps
    Map<Id, Opportunity> newCppOppMap=new  Map<Id, Opportunity>();
    Map<Id, Opportunity> oldCppOppMap=new  Map<Id, Opportunity>();
   
    //Creating New and Old Cpp Opportunity List for before insert and update
    List<Opportunity> oldbfrCppopp = new List<Opportunity>();
    List<Opportunity> newbfrCppopp = new List<Opportunity>();
   
    if((Trigger.isInsert) && (Trigger.isAfter)||(Trigger.IsUpdate && Trigger.isAfter)){
        //The below method is commented as part of the new requirment that child oppotunity will create manually.
        OpportunityLogicHandle.createOpportunity(trigger.new,trigger.old);       
    }
      
    if((Trigger.isUpdate)&& (Trigger.isAfter)){
      
        oldCppopp = Trigger.Old;
        newCppopp = Trigger.new;
        newCppOppMap=Trigger.newMap;
        oldCppOppMap=Trigger.oldMap;      
        OpportunityLogicHandle.createChildOpportunity(oldCppopp,newCppopp );
    }
  
    if(((Trigger.isInsert) && (Trigger.isBefore))||(Trigger.isupdate) && (Trigger.isBefore)){
       
        //Assigining Old Opportunities for Update event as Old date is not avilaible for before insert
        if(Trigger.IsUpdate && Trigger.isBefore){
            oldbfrCppopp=Trigger.Old;
        }
        newbfrCppopp =Trigger.New;
        OpportunityLogicHandle.populateValues(newbfrCppopp,oldbfrCppopp);
    }
   
}
Paul S.Paul S.
Sorry - I suppose I should have asked for the code that includes the recursive check, which I now assume would be the OpportunityLogicHandle class.  Either way, you could change the recursive check statement to also include logic that would check to see if it was the stage that was updated.  If it was, allow the logic to proceed.  Something like:
if(recursive = false || opp.Stage != oldOpp.Stage){
 //code
}
This was selected as the best answer