You need to sign in to do that
Don't have an account?
Hrishikesh Kolhe
Update Account Rating to 'Hot' on account when opportunity stage equals to 'Closed Won' ELSE update account rating to 'Cold' How to deal with above scenario new one---->
Update Account Rating to 'Hot' on account when opportunity stage equals to 'Closed Won' ELSE update account rating to 'Cold'
How to deal with above scenario new one---->
/*Update Account Rating to 'Hot' on account when opp stage equals to 'Closed Won' ELSE update account rating to 'Cold'*/
trigger Accountoppstage2 on Opportunity ( After insert, After update) {
list<Account> acclist= new list<Account>();
Set<Id> accID = new Set<Id>();
Set<Id> ratID= new Set<Id>();
for(Opportunity Opp: Trigger.new){
if(Opp.StageName=='Closed Won'){
AccID.add(Opp.AccountID);
}else{
ratID.add(Opp.ratID);
}
}
for(account acc:[Select Id,Rating from Account where ID In: accID]){
acc.Rating= 'Hot';
acclist.add(acc);
}
for(account acc:[Select Id,Rating from Account where ID In: ratID]){
acc.Rating= 'Cold';
acclist.add(acc);
}
Update acclist;
}
And Facing below error...................>
Variable does not exist: ratID
Thanks in Advance!!!!!
How to deal with above scenario new one---->
/*Update Account Rating to 'Hot' on account when opp stage equals to 'Closed Won' ELSE update account rating to 'Cold'*/
trigger Accountoppstage2 on Opportunity ( After insert, After update) {
list<Account> acclist= new list<Account>();
Set<Id> accID = new Set<Id>();
Set<Id> ratID= new Set<Id>();
for(Opportunity Opp: Trigger.new){
if(Opp.StageName=='Closed Won'){
AccID.add(Opp.AccountID);
}else{
ratID.add(Opp.ratID);
}
}
for(account acc:[Select Id,Rating from Account where ID In: accID]){
acc.Rating= 'Hot';
acclist.add(acc);
}
for(account acc:[Select Id,Rating from Account where ID In: ratID]){
acc.Rating= 'Cold';
acclist.add(acc);
}
Update acclist;
}
And Facing below error...................>
Variable does not exist: ratID
Thanks in Advance!!!!!
Can you try the below code.
If this solution helps, please mark it as best answer.
Thanks,
All Answers
Can you try the below code.
If this solution helps, please mark it as best answer.
Thanks,
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
I see you have posted exactly the same code as mine. Would you be able to take off your comment to avoid confusion of dupliactes for end users.
Thanks,