You need to sign in to do that
Don't have an account?

Generate Map of Map of List
for(Case caseObj : [SELECT Id, ContactId, AccountId FROM Case]) { if(String.isNotBlank(caseObj.AccountId)){ if(!mapId_Map.containsKey(caseObj.AccountId)) { mapId_Map.put(caseObj.AccountId,new Map<Id,List<Case>>()); mapId_Map.get(caseObj.AccountId).put(caseObj.ContactId,new List<Case>()); System.debug('Inside If'); } mapId_Map.get(caseObj.AccountId).get(caseObj.ContactId).add(caseObj); } } System.debug('Map of Map------>>'+mapId_Map);
Getting null pointer exception while adding cases
for(Case caseObj : [SELECT Id,
ContactId,
AccountId
FROM Case]) {
if(String.isNotBlank(caseObj.AccountId)){
if(!mapId_Map.containsKey(caseObj.AccountId)) {
mapId_Map.put(caseObj.AccountId,new Map<Id,List<Case>>());
mapId_Map.get(caseObj.AccountId).put(caseObj.ContactId,new List<Case>());
mapId_Map.get(caseObj.AccountId).get(caseObj.ContactId).add(caseObj);
System.debug('Inside If');
}
}
}
System.debug('Map of Map------>>'+mapId_Map);