Play Games

Search This Blog

Thursday, January 28, 2016

How to prepare map of map in apex

Apex Code :
Map <id, Map <id,Account>> accountMap = new Map <id, Map <id,Account>> ();
for(Account acc : [select id,name from Account]) {
if(accountMap.containsKey(acc.id)) {
accountMap.get(acc.id).put(acc.id,acc);
} else {
accountMap.put(acc.id, new map <id, Account> {acc.id => acc});
}
}

system.debug('accountMapaccountMap'+accountMap);
Output:


No comments:

Post a Comment