function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC New learnerSFDC New learner 

how to iterate over a map and list using a for loop

Hi All,

I am trying to insert and update records based on certain condition.

Map<Id,List<ObjectName>> mapname = new Map<Id,List<ObjectName>>();
for(CustomsettingObject cso : [select id , name ,flag,parentname from CustomsettingObject  where  name =:casepicklistval or parentname =:casepicklistval]{
List<ObjectName> tmp = mapname.get(cso.id);
if(tmp == null) 
tmp = new tmp();
mapname.put(cso.id,tmp);
//how to loop over the map here??
}

CUSTOM SETTING object has records as 
Name                                           TemplateName           Flag             parentname
 SendSurveyForm                               1                         False
SendSurveyAgainwithindays                2                         True            SendSurveyForm

If the flag is False and Parenname is null need to insert in an object and If the Flag is True and Parentname = picklistval then insert another record.
I have written a trigger which get the picklist value and checks for in the Customsetting object and iterates over the map and inserts in the custom object.

How to write this logic?Can anyone give some idea on this that how to loop through the list and insert into a custom object?

Thanks,
SFDC New learner