2

I currently have this very nested wrapper class,

    public sharing class ResultWrapper {

    //This wrapper is contain more wrappers that goes as far as 5 level deep. 
    @AuraEnabled public VerifyResWrapper.ResponseWrapper resResponse { get; set; }
    @AuraEnabled public String AccountId { get; set; }
    }

so, in the service console I am able to see that the data was properly set to the wrapper class

12:23:44:008 USER_DEBUG [22]|DEBUG|result==>ResultWrapper:[resResponse=ResponseWrapper:[Number='123, Detail=OutcomeWrapper:[NextSteps=ContentWrapper:[......

In my lightning controller class it looks something like this...

    @AuraEnabled
public static ResultWrapper getQuestion{
    ResultWrapper resultObject= new ResultWrapper();

    //sample json string.
    string json_string ='...';

    resultObject.AccountId = '1234567';
    resultObject.AuthResponse = (VerifyResWrapper.ResponseWrapper)System.JSON.deserialize(json_string, VerifyResWrapper.ResponseWrapper.class);

    system.debug('Response==>' + result);

    return resultObject; 
}

So when I debug the response.getReturnValue().

console.log('response' + JSON.stringify(response.getReturnValue()));

This is the result it return the Account Id, but showing nothing for the nested wrapper class:

response:{"resResponse":{},"AccountId":"1234567"}

Is there something I a missing here, or had run into a limitation?

  • 1
    I think you need to make each variable of the wrapper class as aura enabled. just the wrapper class definition wont do – RedDevil Dec 10 '18 at 18:09
  • My first thought is that you are using 2 different class attribute names: ResultWrapper.resResponse and ResultWrapper.AuthResponse. Can you include enough code to explain that and also include the ResponseWrapper class in your question? Also, what is in the debug log for the "Response==>" system.debug? – Jeremy Nottingham Dec 10 '18 at 18:33
3

You have to annotate all members of the inner wrapper class as @AuraEnabled whichever wrappers variables you need on UI

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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