You need to sign in to do that
Don't have an account?
Masechaba Maseli 8
attemt to de-reference a null object
Hi all
I am not sure why I am getting this error on my trigger, may someone please point me in the right direction.
I am not sure why I am getting this error on my trigger, may someone please point me in the right direction.
trigger PopulateRegion on Shipment_Order__c (after insert, after update) { for(Shipment_Order__c shipmentorder : Trigger.new) { If(shipmentorder.Hub_Shipment_Formula__c == False ){ string region = Country_Region_List__c.getInstance(shipmentorder.Ship_From_Country__c).Region__c; shipmentorder.Ship_From_Zone1__c = region; } Else { string region3 = Country_Region_List__c.getInstance(shipmentorder.Ship_From_Country__c).Region__c; string region2 = Country_Region_List__c.getInstance(shipmentorder.HUB_Country_Formula__c).Region__c; shipmentorder.Ship_From_Zone1__c = region3; shipmentorder.Hub_Ship_From_Zone__c= region2; } } }
As i observed you have not creating custom setting record with the value of HUB_Country_Formula__c field. Try to add custom setting record and try.
As Abdul Khatri mentioned, dont forget to have a null check.
Let me know if you need more help.
Regards
Naveen
All Answers
The issue is on line 13, the Hub_Shipment__c is a checkbox.
As i observed you have not creating custom setting record with the value of HUB_Country_Formula__c field. Try to add custom setting record and try.
As Abdul Khatri mentioned, dont forget to have a null check.
Let me know if you need more help.
Regards
Naveen
Did you added the value in custom setting and cross checked?
If you did and that helped you to fix the issue, then mark respectrive answer as Best answer.
It was spelled differently. Thank you for the help.