+ Start a Discussion
jneilan22jneilan22 

Tying to Mimic Standard Update() to Fire a Trigger

Hello,

 

Bear with me as I am very new to Apex.  I am an Admin starting to dip my toes into the world of Apex.

 

I have created 2 triggers that work independently, but I need them to work in conjunction with one another.  I created some custom fields on the standard Opportunity object to represent population amounts.  Users can change these fields as population estimates change.  I also created a custom object <Population Assumption> that reads these fields from the Opportunity, applies some percentage assumptions, and returns an adjusted number to a field <Population> on the Population Assumption custom object.

 

The first trigger I created populates the <Population> field on the Population Assumption custom object with the adjusted populations, which I was then hoping to write back to the Opportunity and use in calculations on the Opportunity Product object.  However, I need to have 9 different fields on the Opportunity for the various adjusted populations and I only 3 roll-up summary fields left.

 

The 2nd trigger I created writes the value of the <Population> field referenced above to the Opportunity, but it only works if you edit the custom object records directly.

 

What I need to have is for the 1st trigger work as it does to update the <Population> field on the Population Assumption custom object, but then have the 2nd trigger recognize it as an update and fire to update the Opportunity.

 

Does anyone have sample code that would do this or at least know if it is possible?  I really just need to mimic an update to the custom objects as the trigger update is not recognized by the After Update function.  Thanks.

SrikanthKuruvaSrikanthKuruva

please correct me if my understanding is wrong. your first trigger is

trigger on Population Assumption(...)
{
//populate population field based on some business logic
}

 

and your second trigger is 

trigger on Population Assumption(...)
{
//populate fields on opportunity
}

  

and you want to fire these triggers in sequesnce?

jneilan22jneilan22

Actually, the first trigger is on Opportunity, and yes I want them to fire in sequence.  The problem I seem to be having is that the trigger update performed in trigger 1 is not recognized as an update for trigger 2 to fire.  Thanks.