You need to sign in to do that
Don't have an account?
CvrK
How to write an after update trigger on account to update its related opportunities?
Hi
I am trying to write a simple trigger that updates Stage name,amount fields on Opportunities when its associated account is
updated with the Rating field value as 'Hot',Can someone help me with the Below trigger code which is saved but not working at all.
trigger AutoUpdateOpps on Account(after update) {
List<Opportunity> newOpps = new List<Opportunity>();
for (Account acc : Trigger.old) {
if (acc.Rating=='Hot'){
Opportunity opp = new Opportunity();
opp.StageName = 'Needs Analysis';
opp.Amount = 100,000;
opp.AccountId = acc.Id;
newOpps.add(opp);
}
}
update newOpps;
}
I am trying to write a simple trigger that updates Stage name,amount fields on Opportunities when its associated account is
updated with the Rating field value as 'Hot',Can someone help me with the Below trigger code which is saved but not working at all.
trigger AutoUpdateOpps on Account(after update) {
List<Opportunity> newOpps = new List<Opportunity>();
for (Account acc : Trigger.old) {
if (acc.Rating=='Hot'){
Opportunity opp = new Opportunity();
opp.StageName = 'Needs Analysis';
opp.Amount = 100,000;
opp.AccountId = acc.Id;
newOpps.add(opp);
}
}
update newOpps;
}
MagulanDuraipandian
Check whether this is useful - http://www.infallibletechie.com/2014/08/how-to-update-child-records-when-parent.html