• Bernie_in_Tucson
  • NEWBIE
  • 0 Points
  • Member since 2010

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

I am very new to salesforce, and even newer to Apex.  I'm trying to update a field on my account object, after an opportunity has been closed - won. Here is my first attempt;

 

trigger AccountTypeUpdate on Opportunity (after update) {
   
    Account myAccount=trigger.update[0];
    if (opportunity.StageName = 'A - Closed Won') {
     myAccount.type = 'Customer';
     update myAccount;
    }    //else nothing
}

 

Evidently it doesn't work, and I realize I would have to select the account associated with that opportunity, I'm just not sure how to go about doing that.  Any help would be greatly appreciated.