+ Start a Discussion
Subhrajyoti NathSubhrajyoti Nath 

lightning client side controller returning response error

Hi All,

I have created this below Aura enabled method
@AuraEnabled
    public static Map<Account,List<Contact>> test(String ZipVal, String fldVal)
    {
        Map<Account,List<Contact>> mp = new Map<Account,List<Contact>>();
        Account acc = new Account();
        acc = [select id from Account limit 1];
        mp.put(acc,new list<Contact>());
        mp.get(acc).add([select id from Contact limit 1]);
        return mp;
    }

But in Js Controller it is not able to get the value. The response is coming as error. 
Is map of object and list of object like - Map<Account,List<Contact>> not supported in lightning component?
EswarForceEswarForce
Hi Subhrajyoti Nath,
             I saw the above serverside controller method your trying to send return value is map<Account,List<Contact>> right, Means that single account have multiple contacts.
@AuraEnabled
public static Map<Account,List<Contact>> getPartChildMap(){
Map<Account,List<Contact>> accConMap = new Map<Account,List<Contact>>();
      List<Account> accLIst = [Select id,name,(Select id,name From Contact)From Account];
      if(accLIst  != null && accLIst.size() > 0){
         for(Account acc :accList){
              for(Contact con : acc){
                     if(accConMap.containsKey(con.AccountId)){
                            accConMap.get(con.AccountId).add(con);
                      }else{
                            accConMap.put(con.AccountId,new List<Contact>{con})
                      }
              }
         }
      }

  return accConMap;
}

if your problem get resolve, Please mark it as correct answer it will help to others.

Regards,
Eswarforce.