You need to sign in to do that
Don't have an account?
Trigger to update an Account everytime a related Opportunity's stage changes
Hi,
I need to add a description on my Account every time an Opportunity's stage is changed.
I tried the following and getting NULL pointer exception. Please help:
public class opportunityTriggerHandler {
public static void oppStgChangeDetails(List<Opportunity> oppList, map<Id,Opportunity>oldmap, boolean isInsert, boolean isUpdate){
List<Account> accsToUpdate = New List<Account>();
for(Opportunity opp:oppList){
if(isInsert || (isUpdate && opp.stageName <> oldmap.get(opp.Id).stageName)){
opp.Account.Description = opp.Account.Description + 'Prev Stage: ' +oldmap.get(opp.Id).stageName
+ 'New Stage: '+opp.StageName;
accsToUpdate.add(opp.Account);
}
}
update accsToUpdate;
}
}
Kindly try like below :-
kindly mark it as the best answer if it helps.
Thank you,
Priya Ranjan
All Answers
Kindly try like below :-
kindly mark it as the best answer if it helps.
Thank you,
Priya Ranjan