You need to sign in to do that
Don't have an account?
Jacob W Landis
how to access list by index in the map
Hi,
we have code below, I got error "Initial term of field expression must be a concrete SObject:list<id>", any suggestion?
Map<ID,list<ID>> idMappings = new Map<ID, list<ID>>();
Set<ID> toBeUpdatedIds = new set<ID>();
// then the code to add data into idMappings;
for(Id key: idMappings.keySet()){
if (idMappings.get(key).size()==1){
toBeUpdatedIds.add(idMappings.get(key).get[0]);
}else{
toBeUpdatedIds.add(idMappings.get(key).get[idMappings.get(key).size()-1]);
}
}
we have code below, I got error "Initial term of field expression must be a concrete SObject:list<id>", any suggestion?
Map<ID,list<ID>> idMappings = new Map<ID, list<ID>>();
Set<ID> toBeUpdatedIds = new set<ID>();
// then the code to add data into idMappings;
for(Id key: idMappings.keySet()){
if (idMappings.get(key).size()==1){
toBeUpdatedIds.add(idMappings.get(key).get[0]);
}else{
toBeUpdatedIds.add(idMappings.get(key).get[idMappings.get(key).size()-1]);
}
}
Please try below code. I hope that will help u
Please let us know if this will help u
Just Add
toBeUpdatedIds.add(idMappings.get(key)[0]); to be get value From Map Of List on Index based.