I am currently reading this Salesforce doc: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_apex_returning_data.htm

This is the code provided on the page teaching us that we need to annotate fields we want serialized to the client-side:

public class SimpleAccount {

@AuraEnabled public String Id { get; set; }
@AuraEnabled public String Name { get; set; }
public String Phone { get; set; }

// Trivial constructor, for server-side Apex -> client-side JavaScript
public SimpleAccount(String id, String name, String phone) {
    this.Id = id;
    this.Name = name;
    this.Phone = phone;

// Default, no-arg constructor, for client-side -> server-side
public SimpleAccount() {}

I am confused with the last comment near the no-arg constructor. What does it mean client-side to server-side? Why do we need this constructor?

1 Answer 1


This appears to be flawed. The Phone field is shown as a demonstration of data that will be present in the class, but not sent to the client (because of the missing @AuraEnabled). However, you don't need the zero-args constructor here. Constructors are not called during deserialization of a parameter, so you don't need it, even if you have another constructor defined. That said, it's also not harmful to have the constructor available, as it's basically 1-2 lines of code (depending on how you like to format your curly brackets).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .