You need to sign in to do that
Don't have an account?
Niraj Kumar 9
trigger want to add the functionality that if opportunity owner role = sales specialist then no change in opportunity owner
Hi,
I want to make changes that if opportunity owner role is 'sales specialist' then no change in opportunity owner and for other role
opportunity owner= Account owner.
Here is my code
I want to make changes that if opportunity owner role is 'sales specialist' then no change in opportunity owner and for other role
trigger tocUpdateOpportunitySalesTeamForAccountOwnerChange on Account (before update) { ID[] acc=new ID[]{}; ID[] OwnerIds=new ID[]{}; ID[] oldOwnerIds=new ID[]{}; ID[] oppIds=new ID[]{}; // List<Opportunity> oppToUpdate = new List<Opportunity>(); List <String> OppOldOwnrLst = new List<String>(); for (Integer i = 0; i < Trigger.new.size(); i++) { String id = Trigger.new[i].Id; if(Trigger.new[i].trZuoraID__c==null) { if (Trigger.new[i].OwnerId != Trigger.old[i].OwnerId) { acc.add(Trigger.new[i].Id); OwnerIds.add(Trigger.new[i].OwnerId); oldOwnerIds.add(Trigger.old[i].OwnerId); } } } System.Debug('acc'+acc+'acc.size'+acc.size()); System.Debug('OwnerIds'+OwnerIds+'OwnerIds.size'+OwnerIds.size()); System.Debug('oldOwnerIds'+oldOwnerIds+'oldOwnerIds.size'+oldOwnerIds.size()); if(acc.size()>0) { for(Opportunity opp1:[Select Id,OwnerId, StageName, AccountId from Opportunity Where AccountId IN:acc]) { System.Debug('opp1.OwnerId'+opp1.OwnerId); if(opp1.StageName != ('6. Order Placed') && opp1.StageName != ('7. Order Complete') && opp1.StageName != ('8. Closed / No Order')) { oppIds.add(opp1.Id); OppOldOwnrLst.add(opp1.id+';'+opp1.OwnerId); } } //ProcessDataAccount Class Method Called //ProcessDataAccount.AssignData(acc,OwnerIds,oppIds,oldOwnerIds,OppOldOwnrLst); } }
opportunity owner= Account owner.
Here is my code