function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrew Aldis 15Andrew Aldis 15 

Wrapper Class not completely passing to Lightning Component

I have a wrapper class that is being called by a sfdc lightning component.  For some reason I am not able to access all the values of the class once it is passed.  They are seem to be set in the controller but the lightning controller does not access all of them.  Does anyone know what I am doing wrong.  My code is below.  I did remove some code for brevity.

Controller
@auraEnabled
         public static List<activityWrapper> getAllActivities() {
                     Id usrId = UserInfo.getUserId();
                     List<activityWrapper> allAct = new List<activityWrapper>();
                     dateTime startDate = system.now().addDays(-180);
                         dateTime endDate = system.now().addDays(180);
           List<Id> eventRelationIds = new List<Id>();
                     List<Id> contactIds = new List<Id>();
                      List<Id> accountIds = new List<Id>();
             List<eventRelation> evtRel = [select eventId, relationId, AccountId from eventRelation where event.Owner.id = :usrId and isInvitee = false and event.StartDateTime >= :startDate AND event.StartDateTime <= :endDate order by event.StartDateTime asc ];
             for(eventRelation ev: evtRel) {
               eventRelationIds.add(ev.eventId);
                             contactIds.add(ev.relationId);
                             accountIds.add(ev.AccountId);
             }
           List<Event> eventList = [SELECT Id, Activity_Type__c,recordType.name, whoId, EventWhoIds,  Subject, Short_Description__c, StartDateTime, Description, Activity_Status__c, Owner.Name,  Financial_Account__c, ActivityRelation__c, endDateTime, activityDate FROM event  WHERE Owner.id = :usrId and StartDateTime >= :startDate AND StartDateTime <= :endDate  order by startDateTime asc];
                     List<Contact> contList =[Select Id, Email, MailingCity, MailingStreet, MailingState, MailingCountry, MailingPostalCode, Phone, Account.Name, Name, AccountId from Contact where Id in :contactIds];
                     List<Contact> accContacts = [Select Id, Name, Phone, Email from Contact where AccountId in :accountIds];
                     for(event e: eventList){
                         for(contact c: contList){
                             if(e.whoId == c.Id){
                                string contName = c.Name;
                                  string accName = c.Account.Name;
                               string actStatus = e.Activity_Status__c;
                                  Id accId = c.AccountId;
                              string sub = e.Subject;
                                 string actType = e.Activity_Type__c;
                              Id contId = c.Id;
                                 string descr = e.Description;
                              string phone = c.Phone;
                                 string email = c.Email;
                               date actDate = e.ActivityDate;
                              datetime stDate = e.StartDateTime;
                                datetime eDate = e.EndDateTime;
                                id  eId = e.Id;
                                string actStreet = c.MailingStreet;
                                string  actCity = c.MailingCity;
                                string  actState = c.MailingState;
                                string  actZip = c.MailingPostalCode;
                                string  actCountry = c.MailingCountry;
                                string  actMultiPerson = '';
                                 if(e.EventWhoIds.size() > 1){
                                     actMultiPerson = ' +';
                             }
                                  allAct.add(new activityWrapper(contName, accName, actStatus, accId, sub, actType, contId, descr, phone, email,  actDate, stDate, eDate, eId, actStreet, actCity, actState, actZip, actCountry, actMultiPerson));
                             }
                         }
                     }
                     return allAct;
         }

                 public class activityWrapper{
                    @AuraEnabled public string actContact {get; set;}
                    @AuraEnabled public string actAcc {get; set;}
                    @AuraEnabled public string actStatus {get; set;}
                    @AuraEnabled public id actAccId {get; set;}
                    @AuraEnabled public string actSubject {get; set;}
                    @AuraEnabled public string actType {get; set;}
                    @AuraEnabled public id actContId {get; set;}
                    @AuraEnabled public string actDesc {get; set;}
                    @AuraEnabled public string actPhone {get; set;}
                    @AuraEnabled public string actEmail {get; set;}
                    @AuraEnabled public date actDate {get; set;}
                    @AuraEnabled public dateTime actStDate {get; set;}
                    @AuraEnabled public dateTime actEndDate {get; set;}
          @AuraEnabled public Id actId {get; set;}
                    @AuraEnabled public string actStreet {get; set;}
                    @AuraEnabled public string actCity {get; set;}
                    @AuraEnabled public string actState {get; set;}
                    @AuraEnabled public string actzip {get; set;}
                    @AuraEnabled public string actCountry {get; set;}
                    @AuraEnabled public string actMultiPerson {get; set;}
              public activityWrapper( string contName, string accName, string actStatus, Id accId, string sub, string actType, Id contId, string descr, string phone, string email,  date actDate, datetime stDate,datetime eDate,id  eId,string actStreet,string  actCity,string  actState, string  actZip,string  actCountry,string  actMultiPerson){
                                actContact = contName;
                                actAcc = accName;
                                actStatus =  actStatus;
                                system.debug('*** actStatus2 is '+actStatus);
                                actAccId = accId;
                                actSubject =  sub;
                                actType = actType;
                                actContId = contId;
                                actDesc = descr;
                                actPhone = phone;
                                actEmail = email;
                                actDate = actDate;
                                actStDate = stDate;
                                actEndDate = eDate;
                                actId = eId;
                                actStreet = actStreet;
                                actCity = actCity;
                                actState = actState;
                                actZip = actZip;
                                actCountry = actCountry;
                                actMultiPerson = actMultiPerson;
              }
          }

  init: function(component, event, helper) {

    var allEvents = [];

    var action = component.get('c.getAllActivities');

 
    action.setCallback(this, function(response) {
      var state = response.getState();
      if (state === "SUCCESS") {
        component.set('v.AllActivities', response.getReturnValue());

        allEvents = response.getReturnValue();


      }

    });
    $A.enqueueAction(action);
  },
 
Naveen IlaNaveen Ila
Were you able to Save this code. Since I could n't able to find the fields like AccountId  on EventRelation and EventWhoIds on Event. 
rollorollo
Hi Andrew,

Attributes with null values are not passed to the Lightning Controller.
 
@AuraEnabled
	public static List<Foo> getFoos(){
		List<Foo> foos = new List<Foo>();
		foos.add(new Foo('foo', null));
		foos.add(new Foo(null, 'bar'));
		Contact c = [select Lastname, Email from Contact where Email = null Limit 1];
		foos.add(new Foo(c.Lastname, c.Email));
		return foos;
	}

	public class Foo {
		public @AuraEnabled String foo;
		public @AuraEnabled String bar;

		public Foo(String foo, String bar){
			this.foo = foo;
			this.bar = bar;
		}
	}
This is the result of a console.log() for this list.
[
  {"foo":"foo"},
  {"bar":"bar"},
  {"foo":"Prang"}
]

Best Roland