You need to sign in to do that
Don't have an account?
Null Point Exception
Can some please review this and iam getting an null point exception at the line which is marked in red.
public List<Voucher__c> getRelatedVoucher() {
NumberEventsBenefiting = 0;
TotalRaffles = 0;
TotalEvents = 0;
RelatedVoucher = new List<Voucher__c>();
RelatedTreasureChestApplications = new List<Treasure_Chest_Application__c>();
this.Voucherid = 'a1Ac0000000VaCi';
if(Voucherid != null && Voucherid!= ''){
for(Voucher__c queryvouchers : [select (select Amount_Raised_for_Event__c,CreatedDate,Stage__c, Date_Accepted__c,
Amount_Raised_for_Voucher__c, Location_of_event__c,Name_of_the_Event__c,
Date_of_the_Event__c,Temporary_Voucher__r.Account__r.Name
from Treasure_Chest_Applications__r )
Total_Amount_Raised_for_Events__c,Total_Amount_Raised_for_Vouchers__c,Number_of_Events_Benefiting__c,Term__c,
Name,CreatedDate from Voucher__c where id=: Voucherid ]){
for(Treasure_Chest_Application__c TCA :queryvouchers.Treasure_Chest_Applications__r){
if((date.today().month() - TCA.Date_of_the_Event__c.month() == 1) && (date.today().year() == TCA.Date_of_the_Event__c.year())){
RelatedVoucher.add(queryvouchers);
}
}
}
for(Voucher__c CalVouchers : RelatedVoucher ){
NumberEventsBenefiting += Integer.valueOf(CalVouchers.Number_of_Events_Benefiting__c);
TotalRaffles += Integer.valueOf(CalVouchers.Total_Amount_Raised_for_Vouchers__c);
TotalEvents += Integer.valueOf(CalVouchers.Total_Amount_Raised_for_Events__c);
}
}
return RelatedVoucher;
}
try this,
All Answers
How do i check the null before accessing?
try this,