3 Antworten
Hi Aman,trigger ProjectAlchemyFieldMandatory on Opportunity (after insert,after update) { Set<Id> Accids=new Set<Id>(); if(trigger.isInsert || trigger.isUpdate) { for(Opportunity Opp:Trigger.new) { Accids.add(opp.Accountid); system.debug('@@@@@Accids'+Accids); } } List<Account> lisAcc=[select id,Checkbox__C,(select id,Service__C from opportunities) from account where id in:Accids]; for(Account acc: lisAcc) { system.debug('Checkbox__C'+acc.Checkbox__C); if(acc.Checkbox__C==true) { for(Opportunity op:acc.opportunities) { system.debug('Service__C for loop'+op.Service__C ); if(op.Service__C==null || op.Service__C=='') { system.debug('@@@@@Service__C'+op.Service__C); Opportunity actualRecord = Trigger.newMap.get(op.Id); actualRecord.adderror('Please select'); } } } } }I am getting this error when i create a new record in opportunity.execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.ProjectAlchemyFieldMandatory: line 28, column 1Trigger.newMap.get(op.Id);--> this line gives null valueThanksSatheesh K