You need to sign in to do that
Don't have an account?
RAG_SFDC
Adding values into Nested maps
Hi Guys,
I am trying to add values into nested map
here it is
Map<String,Map<String,Map<String,List<Case>>>> xyz Map = new Map<String,Map<String,Map<String,List<Case>>>>();
How to add values to this map.
Appreciate your help :)
Before anything else you probably want to rethink why you need such a nested set of maps. An Internal class wrapper object is probably better and a lot easier to manage.
In any case, if you really want to keep using the nested map structure... you can do something like this:
All Answers
Before anything else you probably want to rethink why you need such a nested set of maps. An Internal class wrapper object is probably better and a lot easier to manage.
In any case, if you really want to keep using the nested map structure... you can do something like this:
here is very simple example to get idea of putting values in nested Map:
List<String> SourceList = new List<String>{'TestData1','TestData2'};
List<String> innerKeys = new List<String>{'innerOne','innerTwo'};
List<String> values = new List<String>{'valueOne','valueTwo'};
Map<String,Map<String,String>> NestedMAp = new Map<String,Map<String,String>>();
Map<String,String> interMap
for(Integer i = 0; i< SourceList.size(); i++){
interMap = new Map<String,String>();
for(Integer j = 0; j<innerKeys.size(); j++){
interMap.put(innerKeys[j],values[j]);
}
NestedMAp.put(SourceList[i],interMap);
}
Perfect :)
Thanks Guys