map<id,map<id,opportunity>> ao = new map<id,map<id,opportunity>>();
map<id,account> ac = new map<id,account>([select id from account]);
for(Opportunity record:[select id,accountid from opportunity where accountid in :ac.keyset()]) {
if(!ao.containskey(record.accountid)) {
ao.put(record.accountid,new map<id,opportunity>());
}
ao.get(record.accountid).put(record.id,record);
}
for(Id accountId:ao.keyset()) {
for(Id oppId:ao.get(accountId).keyset()) {
// ac.get(accountid) and ao.get(accountid).get(oppid)
// are account and opportunity, respectively.
}
}
If this solution is usefull for you, Please mark as a Best Answer to help others.
Thanks Mukesh, for your input but I am looking for how to access this map of map values in lightning components.
Please find here the stucture of my problem-
public Map<String,Map<String,Decimal>> mapExpDetails{get;set;}
I have created the attribute the in component and assigned the value to this attribute though controller. <aura:attribute name="mapexpensedet" type="Map"/>
Now , I want to print all the values of this like - mapExpDetails.get('MonthlyLeaseAmount').get('Jan')
I have represented it in apex , Can you help me with how can I access it similarly in lightning component?
<aura:attribute name = "yourData" type="Object" default="{}"/>
In this case, yourData will store your map and the values can be accessed in standard Javascript ways after it is set, but with one caveat. Because it's not initialized as a map and because it's essentially blank, before attempting to access your data, error checking with $A.util.isEmpty() is heavily advised.
Can you please share your collection structure first.
Forr Example You Can use this code :
If this solution is usefull for you, Please mark as a Best Answer to help others.
Regards
Mukesh
Please find here the stucture of my problem-
public Map<String,Map<String,Decimal>> mapExpDetails{get;set;}
I have created the attribute the in component and assigned the value to this attribute though controller.
<aura:attribute name="mapexpensedet" type="Map"/>
Now , I want to print all the values of this like -
mapExpDetails.get('MonthlyLeaseAmount').get('Jan')
I have represented it in apex , Can you help me with how can I access it similarly in lightning component?
The Lightning component has to have:
<aura:attribute name = "yourData" type="Object" default="{}"/>
In this case, yourData will store your map and the values can be accessed in standard Javascript ways after it is set, but with one caveat. Because it's not initialized as a map and because it's essentially blank, before attempting to access your data, error checking with $A.util.isEmpty() is heavily advised.