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
Animesh DattaAnimesh Datta 

Get Map Id in outer loop for map of map<id, list<sObject>>

colGrpMemberMap = new Map<Id, List<CollaborationGroupMember>>();

for(ID groupId: colGrpMemberMap.keySet()){
                ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
                    //ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
                    feedItemInput.body = messageInput;
                    feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
                    feedItemInput.subjectId = colGrpMemberMap.get(groupId);
                    for(CollaborationGroupMember grpMemberId : colGrpMemberMap.get(groupId)){
                            ConnectApi.MentionSegmentInput mentionSegment = new ConnectApi.MentionSegmentInput();
                            //feedItemInput.subjectId = grpMemberId.CollaborationGroupId;
                   = grpMemberId.MemberId ;
                    ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput, null);

can you please tell me how to get Map id in bold line. I am unable to get map id in outer for loop.

Hi Animesh,

You can outright use groupId at line no.8, which would be your map key:

feedItemInput.subjectId = groupId;
Animesh DattaAnimesh Datta
Thanks for your response Pankaj. I tries the same at 1st moment but i am not getting it. I do not know where I am making mistake