4 respuestas
Hi Choccy, I have written the same code in another way, hope this one workstrigger NewAccountOppTEST on Account (After insert) { List<Opportunity> OppList = new List<Opportunity>();List<Account> accList = [select Id, SLA__c from Account where Id IN:Trigger.new]; //Auto populate SLA field for new account and create related opportunity for (account acc : accList ){ acc.SLA__c = 'Gold'; Opportunity opp = new Opportunity(); opp.name = 'Auto Created again'; opp.CloseDate = Date.today()+7; opp.Stagename = 'Prospecting'; opp.AccountID = acc.id; OppList.add(opp);} update accList;if(OppList.size() >0) {Insert OppList;}}Thanks Surya G