You need to sign in to do that
Don't have an account?
Karen Hanson
trigger error Prospect
i have a requirement when only account field type update to Prospect the related opp stage name update's Prospect ,but her whenever i chage any field in account . the opp stage names update's Prospect .
trigger updateopportunities on Account(after update) { Set<Id> accountIds = new Set<Id>(); //new set of IDs for(Account ac : Trigger.new) //bulklification { { if(ac.Type!=trigger.oldMap.get(ac.Id).name) // er if(ac.Type=='Prospect') //if axcount if of prospect accountIds.add(ac.Id); //add it to set values { } List<Opportunity> oppsToUpdate = new List<Opportunity>(); //new list for(Opportunity opp : [select id, StageName from Opportunity where AccountId in: accountIds]) //bulklification query for stagename ,id from opportunity { opp.StageName='Prospect'; oppsToUpdate.add(opp); // adding to the list } update oppsToUpdate; //update the opp } } }
Best Answer chosen by Karen Hanson
Kbhaskar
use this