• learncloud
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi,

I am new to sfdc, i would like o update account object field based on opportunity object field values

below is my code what i tried but im getting error. - Error: Compile Error: Variable does not exist: ac at line 20 column 8

trigger Account on Opportunity (after update)
 {

 if (Trigger.isUpdate)
 {

list<Account> acc = new list<Account>();

for(Opportunity opp: trigger.new)
{

Account ac = new Account();
ac.Status__c = opp.StageName;
if(opp.StageName == 'Closed Won')
{
ac.Status__c = 'Customer';
}
}

update ac;

}
}