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
CvrKCvrK 

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;
}
MagulanDuraipandianMagulanDuraipandian
Check whether this is useful - http://www.infallibletechie.com/2014/08/how-to-update-child-records-when-parent.html