+ Start a Discussion
Travis Malle 9Travis Malle 9 

wrapper class probables

Hello All,
 I’m having some trouble wrapping my head around wrapper classes (pun intended). The basics of what I’m trying to accomplish is to create a map where the key is a concatenation of two strings and the value is a wrapper list that holds multiple primitives. I have done some reading but can’t seem to get it working. The error I’m getting is line 30 “Method does not exist or incorrect signature: [List<OfficerStats_CampaignUpdate.CampAggWrperBooked>].add(String, Date, Integer, Integer, Integer)”. Can someone please help me understand what I’m doing wrong.
 
public class OfficerStats_CampaignUpdate {
    
    public list <Campaign> triggerVarNew;
    public list <Campaign> triggerVarOld;
    
	// Main Class Constructor    
    public OfficerStats_CampaignUpdate (list<Campaign> triggerContNew, list<Campaign> triggerContOld){
        triggerVarNew = triggerContNew;
        triggerVarOld = triggerContOld;
        
		// Get list of effected dates and add to set (from new and old trigger records)
        set<date> EffectedDates = new set<date>();    
        for(Campaign TriggValNew : TriggerVarNew){EffectedDates.add(Date.valueof(TriggValNew.End_Date_Time__c));}
        for(Campaign TriggValOld : TriggerVarOld){EffectedDates.add(Date.valueof(TriggValOld.End_Date_Time__c));}
        
        // get agg result list of campaings within specific dates
        list <aggregateResult> CampaignAggResult = ([SELECT Count(id) countid, sum(New_Memberships__c) Memberships, DAY_ONLY(End_Date_time__c) EventDate, sum(referral_total__c) Referrals, Booked_by__c BookedBy, GROUPING(Booked_By__c) GRPBooked  
                                                     FROM Campaign
                                                     WHERE Status = 'Completed'
                                                     AND DAY_ONLY(End_Date_Time__c) in : EffectedDates
                                                     GROUP BY CUBE (Booked_By__c, DAY_ONLY(End_Date_time__c))
                                                     ORDER BY GROUPING (Booked_by__c)]);
        
		// For each agg result line, check to see if bookedby is null, if not null add to list, then add list to    map value   
        map <string,CampAggWrperBooked> WrapperMap = new map <string,CampAggWrperBooked>();
        
        for (AggregateResult ar : CampaignAggResult){
            if(ar.get('BookedBy') != null){
            	list <CampAggWrperBooked> BookedWrapperList =  new list <CampAggWrperBooked>();
                    BookedWrapperList.add(string.valueof(ar.get('bookedBy')), date.valueof(ar.get('EventDate')), integer.valueof(ar.get('Memberships')), integer.valueof(ar.get('Referrals')), integer.valueof(ar.get('countid')));
                
            }
            
        }
        
    }
      
	// Wrapper Class
    public class CampAggWrperBooked {
        public string BookedBy;
        public date EndDate;
        Public integer SumOfMembers;
        public integer SumOfReferrals;
        Public integer EventCount;
		// Wrapper Constructor            
        public CampAggWrperBooked(string BookedByWrap, date EndDateWrap, integer SumOfMembersWrap, integer SumOfReferralsWrap, integer EventCountWrap){
            this.BookedBy = BookedByWrap;
            this.EndDate = EndDateWrap;
            this.SumOfMembers = SumOfMembersWrap;
            this.SumOfReferrals = SumOfReferralsWrap;
            this.EventCount = EventCountWrap;
        }            
    }   
}


 
Best Answer chosen by Travis Malle 9
Nagendra Prasad ChNagendra Prasad Ch
Hi,
Change line no 30 to this,
 
BookedWrapperList.add(new CampAggWrperBooked (string.valueof(ar.get('bookedBy')), date.valueof(ar.get('EventDate')), integer.valueof(ar.get('Memberships')), integer.valueof(ar.get('Referrals')), integer.valueof(ar.get('countid'))));

Please let me know if it helps.

Thanks,
Nagendra Prasad

All Answers

Nagendra Prasad ChNagendra Prasad Ch
Hi,
Change line no 30 to this,
 
BookedWrapperList.add(new CampAggWrperBooked (string.valueof(ar.get('bookedBy')), date.valueof(ar.get('EventDate')), integer.valueof(ar.get('Memberships')), integer.valueof(ar.get('Referrals')), integer.valueof(ar.get('countid'))));

Please let me know if it helps.

Thanks,
Nagendra Prasad
This was selected as the best answer
Travis Malle 9Travis Malle 9
Thank you... worked perfect