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
rammramm 

hw can i auto update oppurnity ammount to account amount in triggers

Vyankatesh Choulwar 15Vyankatesh Choulwar 15
Hi Ashoka,

You have to query on opportunity with where condition as ' Opportunity.Accountid = Accountid ". Here  Accountid is your current account id and get the relevant opportunity.
Then update opportunity as opp.ammount = acc.ammount.

Thanks,
Vyankatesh
karthikeyan perumalkarthikeyan perumal
Hello

use below code 
 
trigger UpdateAccountAmount on Account(Before update) {


for(Account Accnt:Trigger.New)
{
  for(Opportunity CurrOpp :[Select Amount from Opportunity where Accountid=:Accnt.id])
  {
    Accnt.Amount__c=CurrOpp.Amount;
    
  }
}

}
if Amount__c is text field  replace below code 

Accnt.Amount__c=strin.valueof(CurrOpp.Amount);

Hope this will help you,
Mark Solved if its work for you.

Thanks
karthik
 
Salesforce####Salesforce####
just a small typo mistake for above :   Accnt.Amount__c= String.valueOf(CurrOpp.amount);
karthikeyan perumalkarthikeyan perumal
thanks
mark it best answer if its workd for you.. to help others for same issue.