Skip to main content
learn sfdc ha preguntado en #Apex
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;

}

}
2 respuestas
  1. 5 may 2017, 16:19
    Hello LearnCloud,

    Can you please explain what are you trying to do here and I will see If I can help you out..

    It's looks like you have field Status__c on account which needs to be same as opportunity's stage field. If yes, then one account can have many opportunities and which opportunity's stage field should be set as account's Status__c?
0/9000