I have the below apex method returning the below Map
@AuraEnabled(cacheable=true)
public static Map<String, AccountDtls> getActiveLstng(Id accountId ){
<<code returning the map>>
}
The above method returns the Account details and List of Opportunity lineitems of all the Child accounts in the form of wrapper class for the passed Parent account id
Below is the structure of wrapper class:
Class AccountDtls {
public String accName { set; get; }
public String cpoMake { set; get; }
public List<OpportunityLineItem> olis { set; get; }
public AccountDtls(String accName, String cpoMake, List<OpportunityLineItem> olis) {
this.accName = accName;
this.cpoMake = cpoMake;
this.olis = olis;
}
}
In my LWC component:
Goal is to form the html content in the attached image from js based on the Map returned from wire apex and pass it as the value for lightning-input-rich-text element
Problems:
- How do read the wrapper value (AccountDtls) based on Account id (key) in JS. console.log JSON.stringify(result[key]) is printing [object Object]
- I want to read the wrapper value (AccountDtls) based on Account id (key) and then read the List property within JS
can anyone suggest how can I do this within JS?
wireAccnts({data,error}){
if(data){
console.log('Inside data==>', data);
var result = data; //Map<String, AccountDtls>
for(var key in result){
console.log('Inside key==>'+ key)
if (result.hasOwnProperty(key)){
console.log('Inside result[key] ==>'+ JSON.stringify(result[key]))
//this.mapOfAcctDlts.push({key: key, value : result[key] })
}
}
}