• kandy11
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

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 Total_Amount_Raised_for_Events__c,Total_Amount_Raised_for_Vouchers__c,Number_of_Events_Benefiting__c,Term__c,
Name,CreatedDate, (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 )
from Voucher__c where id=: Voucherid ]){

for(Treasure_Chest_Application__c TCA :queryvouchers.Treasure_Chest_Applications__r){
if(TCA.Date_of_the_Event__c != null){

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 ){
for(Treasure_Chest_Application__c TCA1 :CalVouchers.Treasure_Chest_Applications__r){
if((date.today().month() - TCA1.Date_of_the_Event__c.month() == 1) && (date.today().year() == TCA1.Date_of_the_Event__c.year())){



NumberEventsBenefiting = Integer.valueOf(CalVouchers.Number_of_Events_Benefiting__c);
TotalRaffles += Integer.valueOf(TCA1.Amount_Raised_for_Voucher__c);
TotalEvents += Integer.valueOf(TCA1.Amount_Raised_for_Event__c);
system.debug('&&&&&&&&&&&&&&&&&&&&&&&&&&&'+ TotalRaffles);

}
}
}
}
return RelatedVoucher;
}

 

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;
}

hello

 

Iam getting an invalid foreign key relationship error

 

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 ])

 

{
if((date.today().month() - queryvouchers.Treasure_Chest_Applications__r.Date_of_the_Event__c.month() == 1) && (date.today().year() == queryvouchers.Treasure_Chest_Applications__r.Date_of_the_Event__c.year())) {
RelatedVoucher.add(queryvouchers);

 

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;
}

hello

 

Iam getting an invalid foreign key relationship error

 

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 ])

 

{
if((date.today().month() - queryvouchers.Treasure_Chest_Applications__r.Date_of_the_Event__c.month() == 1) && (date.today().year() == queryvouchers.Treasure_Chest_Applications__r.Date_of_the_Event__c.year())) {
RelatedVoucher.add(queryvouchers);