I am trying to pass a list of objects to Apex from an LWC controller, and it looks like the Apex controller is getting the right sized list, but nothing is populated. Does anybody have any idea of what could be the problem?

Component JS code

refreshPeople() {
    let xxx = [];

    xxx.push({name : 'aaa', email : 'bbb'});
    xxx.push({name : '111', email : '222'});

    getPeople({peopleInfo: xxx})
        .then(result => {
            console.log('#### HERE');
            this.allPeople2 = result;
        .catch(error => {
            //Error Handling goes here


@AuraEnabled(cacheable = true)
public static List<EmailPerson> getPeople(List<EmailPerson> peopleInfo) {
    try {

        System.debug('####' + peopleInfo);

        return null;
    } catch (Exception e) {
        throw new AuraHandledException(e.getMessage() + ' ' + e.getStackTraceString());

public class EmailPerson {
    public Id id;
    public String name;
    public String email;
    public Id recordTypeId;
    public String recordTypeName;

Note: I've tried @wire, the behavior is the same. The list sees the two items, but none the values on the properties are assigned

<17:00:38:006 USER_DEBUG [20]|DEBUG|####(EmailPerson:[email=null, name=null], EmailPerson:[email=null, name=null])


After 2 hours of struggling, and only 5 minutes after posting, here is the answer:

You have to add add {get;set;} explicitly for this to work. Changing my inner class to the below fixed the problem.

public class EmailPerson {
    public Id id {get;set;}
    public String name {get;set;}
    public String email {get;set;}
    public Id recordTypeId {get;set;}
    public String recordTypeName {get;set;}
  • 3
    Its so weird that they expect this and just @auraEnabled is not sufficient .Will be curious for explanation from SFDC LWC Product team why do we need get and set on properties . – Mohith Shrivastava Apr 9 '19 at 0:26
  • 1
    I’d love to hear it as well. That’s 2 hours of the clients time down the drain. – Sebastian Kessel Apr 9 '19 at 0:27
  • 1
    This is exactly why I avoid wrappers and use the Map<String, Object> datatypes. – tsalb Apr 9 '19 at 2:41
  • FYI, I made an answer here about dealing with complex datatypes without wrappers. – tsalb Apr 9 '19 at 5:49
  • 1
    Using Map<String, Object> creates too loose of a contract between the UI and backend. It opens the door for runtime bugs. Thanks for the answer! – Charles Naccio Apr 23 '19 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.