You need to sign in to do that
Don't have an account?
D'Mario Lewis
Map of Maps
Im creating map of a map of allocations using a church number as my key. The issue with my code is when I use the map.get(key) function and enter a church number I returns the last element map and I cant understand why.
private Map<String, Map<String, Decimal>> AboveMinistryShareAllocationMap(List<causeview__Gift_Detail__c> allocationlist){ Map<String, Map<String, Decimal>> Level1Above = new Map<String, Map<String, Decimal>>(); Map<String, Decimal> Level2Above = new Map<String, Decimal> (); String churchnumber = allocationlist.get(0).churchnumber; Decimal amount = 0; for(causeview__Gift_Detail__c allocation : allocationlist){ String allChurch = allocation.churchnumber; String fundname = allocation.fundnote; if(allChurch.equals(churchnumber)){ amount += allocation.amount Level2Above.put(fundname, amount); } else { Level1Above.put(churchnumber, Level2Above); Level2Above.clear(); amount = allocation.causeview__Approved_Amount__c; Level2Above.put(fundname, amount); churchnumber = allChurch; } } return Level1Above; }