0

I have custom Wrapper class

public without sharing class OppProdWrapper {
    public String Name;
    public Decimal UnitPrice;
    public Decimal TotalPrice;
       
    public OppProdWrapper(String Name, Decimal UnitPrice, Decimal TotalPrice) {
        this.Name = Name;
        this.UnitPrice = UnitPrice;
        this.TotalPrice = TotalPrice;
    }
}

And I use it in controller to get related fields and return to lwc.

        List<OppProdWrapper> oppProdWrappers = new List<OppProdWrapper>();
        for (OpportunityLineItem oppProd : oppProds) {
            OppProdWrapper wrapper = new OppProdWrapper(
                oppProd.Product2.Name,
                oppProd.UnitPrice,
                oppProd.TotalPrice
            );
            oppProdWrappers.add(wrapper);
        }

I start debug and see that all needed fields receive data but when

oppProdWrappers.add(wrapper);

execute, oppProdWrappers don't receive this data. Why is that?

1 Answer 1

1

To use a variable in lightning component use @AuraEnabled Annotation before the variable name.

Example

public class WrapperAccount {
    @auraenabled
    public string name{get;set;}
    @auraenabled
    public integer numberOfEmployees{get;set;}
    @AuraEnabled
    public List<Contact> contacts { get; set; }
}
1
  • Thank you :-) It works!
    – Yauheni
    Jun 29, 2022 at 18:04

You must log in to answer this question.

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