You need to sign in to do that
Don't have an account?

System.Null Pointer Exception in Trigger
Hi All,
I am getting system.null pointer exception: attempt to de-reference a null object, when trying to insert a record with null value in date field.
How to resolve this error. Need your assistance to fix this issue.
Below is my Trigger:
Thanks
I am getting system.null pointer exception: attempt to de-reference a null object, when trying to insert a record with null value in date field.
How to resolve this error. Need your assistance to fix this issue.
Below is my Trigger:
Trigger: trigger insertDailyPractices on Study_Plan__c (after insert) { System.debug('--- Inside Trigger ---'); List<Daily_Practice__c> dplist = new List<Daily_Practice__c>(); for(Study_Plan__c sp : Trigger.New) { Integer daycount = sp.Phase_Start_Date__c.daysBetween(sp.Phase_End_Date__c); ----/// Getting error in this line. System.debug('--- Inside For Loop ---' + sp.Phase_Start_Date__c); System.debug('--- Day Count ---' + daycount); for(integer i=0; i<=daycount; i++) { Daily_Practice__c dps = new Daily_Practice__c(); dps.Due_Date__c = sp.Phase_Start_Date__c.addDays(i) + 1; dps.StudyPlan__c = sp.Id; dps.Status__c = 'Assigned'; dplist.add(dps); } } if(dplist.size() > 0) { insert dplist; } system.debug('--- Inserted Daily Practice ---'+ dplist.size()); }
Thanks
I have just tried to cover your issues with null checks which is part of coding consideration
All Answers
HTH
Andrew G
Thanks for your reply.
after updating the code as suggested am getting below error. Can you look and let me know.
Method does not exist or incorrect signature: void isNotBlank(Date) from the type String at line 8 column 19
I have just tried to cover your issues with null checks which is part of coding consideration
Thanks for your help.. It is working fine.