You need to sign in to do that
Don't have an account?
Sharndeepkaur
iterate map of Id and list of sobject
Eg I have Map1: Map<Id,List<FeedComment>>
So i am creating Map of FeedItem and its related FeedComments
Now after filling this map i want to access FeedComment field (eg createdbyid) and place this Field Id in Set and use it.How can do that without iterating 'Map1' 2 times in for loop?
So i am creating Map of FeedItem and its related FeedComments
Now after filling this map i want to access FeedComment field (eg createdbyid) and place this Field Id in Set and use it.How can do that without iterating 'Map1' 2 times in for loop?
You can try this one ,
Set<Id>fieldCreatedByIdSet= new Set<Id>();
for(Id i:Map1.Keyset()){
for(FeedComment feed :Map1.get(i)){
fieldCreatedByIdSet.add(feed.CreatedById);
}
}
Pls Mark it as Best answer If You find it helpful !!
Thanks
Thank you for the response.
Yes,i can get value like this but here we have to first iterate Keyset and then again use inner for loop for getting values.Is there another way to do this without using 2 for loops?
I have read in Sf docs that we have to avoid using double for loops and use Map instead or something else.Can you please assist regarding this?