How to get my desired Map id list sobject salesforce?
I have below code where I face error as incompatible type. Can someone please help me resolve it? I can't get how to populate it.
Apex Code
Map> accATLMap = new Map .........>();
for(Account_Territory_Loader_vod__c atl: atlList) {
if(accATLMap.get(atl.account_vod__c) == null)
accATLMap.put(atl.account_vod__c,atl); // This line gets error out
}
you can use below code to get your desired Map id list sobject salesforce: -
for(Account_Territory_Loader_vod__c atl: atlList) {
if(accATLMap.containsKey(atl.account_vod__c) && accATLMap.get(atl.account_vod__c) != null) {
List lst_terr = accATLMap.get(atl.account_vod__c);
lst_terr.add(atl);
accATLMap.put(atl.account_vod__c,lst_terr);
}
else {
accATLMap.put(atl.account_vod__c, new List {atl});
}
}
I hope it solves your purpose.