-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
3Replies
Values of fields are getting doubled from different recvords of same object....
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;
}
-
- kandy11
- November 11, 2013
- Like
- 0
- Continue reading or reply
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;
}
-
- kandy11
- November 05, 2013
- Like
- 0
- Continue reading or reply
Invalid foreign key relationship
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);
-
- kandy11
- November 04, 2013
- Like
- 0
- Continue reading or reply
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;
}
- kandy11
- November 05, 2013
- Like
- 0
- Continue reading or reply
Invalid foreign key relationship
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);
- kandy11
- November 04, 2013
- Like
- 0
- Continue reading or reply