You need to sign in to do that
Don't have an account?
PC
insert key of map as parent objects and value of map as child objects
I need to insert key of map as parent objects and value of map as child object.
How can we do this?
Map<Case,List<Case>> parentChildMap = new Map<Case,List<Case>>();
How can we do this?
If you find this answer helpful, Please mark it as the best answer.
You can try below code,
public class InsertCaseMap {
public static void methForCase(){
Map<Case,list<Case>> caseslist=new Map<Case,list<Case>>();
list<Case> caselist=[SELECT id,(SELECT id from Cases) FROM Case];
for(Case cs:caselist){
caseslist.put(cs,cs.Cases);
}
system.debug(caseslist);
}
}
Hope this will help you.
Thanks.