You need to sign in to do that
Don't have an account?
Femila Ice Cream
I am getting "NullPointerException: Argument cannot be null." error for following code when i am tring to save the record
trigger total on Outlet_Billing__c (before insert, before update) {
if(Trigger.isBefore){
decimal d;
if (Trigger.isInsert || Trigger.isUpdate)
{
for(Outlet_Billing__c out : trigger.new)
// try {
out.Total__c= out.WaterCandyForm__c+
out.KulfiCandyForm__c+
out.DuetForm__c+
out.BabyChocobarFormula__c+
out.BigConeForm__c+
out.Butterscotch_1000mlForm__c+
out.Butterscotch_4Ltr_BulkForm__c+
out.Butterscotch_500mlForm__c+
out.CasattaForm__c+
out.Chocolate_1000mlForm__c+
out.Chocolate4LtrForm__c+
out.Large_Cup_ButterscotchForm__c;
}
// catch (System.NullPointerException e) {
// }
}
}
if(Trigger.isBefore){
decimal d;
if (Trigger.isInsert || Trigger.isUpdate)
{
for(Outlet_Billing__c out : trigger.new)
// try {
out.Total__c= out.WaterCandyForm__c+
out.KulfiCandyForm__c+
out.DuetForm__c+
out.BabyChocobarFormula__c+
out.BigConeForm__c+
out.Butterscotch_1000mlForm__c+
out.Butterscotch_4Ltr_BulkForm__c+
out.Butterscotch_500mlForm__c+
out.CasattaForm__c+
out.Chocolate_1000mlForm__c+
out.Chocolate4LtrForm__c+
out.Large_Cup_ButterscotchForm__c;
}
// catch (System.NullPointerException e) {
// }
}
}
That is beause one of the fields you are trying to add returning null value.
so before adding that feild value to Total__C do null check.Make 0 as default value for all the number fields.
Thanks.
All Answers
That is beause one of the fields you are trying to add returning null value.
so before adding that feild value to Total__C do null check.Make 0 as default value for all the number fields.
Thanks.