You need to sign in to do that
Don't have an account?
Tapas Tulo
An account has many opportunity,there is a PickList field on opportunnity called status(value-approved,rejected,hold).
An account has many opportunity,there is a PickList field on opportunnity called status(value-approved,rejected,hold).
Scenario -
whenever one opportunity status get updated to APPROVED other should be rejected.
Here My Code-
Apex Class:-
public class AccountOpty {
List<Account> acctToUpdate = new List<Account>();
List<Opportunity> opps = new List<Opportunity>();
Set<Id> associatedAccId = new Set<Id>() ;
public static void findOpty(list<Opportunity> oppList){
for(opportunity opp:oppList){
associatedAccId.add(opp.AccountId) ;
}
//opps=[select id,AccountId From Opportunity ];
}//End OF findOpty ethod
}//End Of Class
My Trigger:-
trigger AccountOptyAfterTrigger on Opportunity (after Update) {
AccountOpty.findOpty(trigger.new);
}
after executing my apex class am getting the below Error
Error: Compile Error: Variable does not exist: AccountId at line 8 column 29
Scenario -
whenever one opportunity status get updated to APPROVED other should be rejected.
Here My Code-
Apex Class:-
public class AccountOpty {
List<Account> acctToUpdate = new List<Account>();
List<Opportunity> opps = new List<Opportunity>();
Set<Id> associatedAccId = new Set<Id>() ;
public static void findOpty(list<Opportunity> oppList){
for(opportunity opp:oppList){
associatedAccId.add(opp.AccountId) ;
}
//opps=[select id,AccountId From Opportunity ];
}//End OF findOpty ethod
}//End Of Class
My Trigger:-
trigger AccountOptyAfterTrigger on Opportunity (after Update) {
AccountOpty.findOpty(trigger.new);
}
after executing my apex class am getting the below Error
Error: Compile Error: Variable does not exist: AccountId at line 8 column 29
We cannot use outside declared variables in Statux classes. Either the variable should be declared as Static or it should be declared inside the Static method.
Please find below modified Apex Class:
OR
Let us know if that helps you.
Best Regards,
BALAJI
Thank You For quick Your Responce.
after i execute Your Code am getting the below Error(almost same as mine).
Error: Compile Error: Variable does not exist: AccountId at line 9 column 29
Are you running the code as System Administrator profile ?
But AccountId is a Standard Field in Opportunity.
Can you try this at line 9
Hi Tapas,
Try this one:
I hope it helps you. Please mark this as best answer if it helps you, so that it would be helpful ton others.
Thanks,
Yogesh Sharma