Newer Version Available

This content describes an older version of this product. View Latest

Post a Comment with a Mention

This example calls postCommentToFeedElement(String, String, ConnectApi.CommentInput, ConnectApi.BinaryInput) to post a comment that mentions a group.
1swfobject.registerObject("clippy.codeblock-0", "9");String communityId = null;
2String feedElementId = '0D5D0000000KtW3';
3
4ConnectApi.CommentInput commentInput = new ConnectApi.CommentInput();
5ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
6ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
7ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
8
9messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
10
11textSegmentInput.text = 'Does anyone in this group have an idea? ';
12messageBodyInput.messageSegments.add(textSegmentInput);
13
14mentionSegmentInput.id = '0F9D00000000oOT';
15messageBodyInput.messageSegments.add(mentionSegmentInput);
16
17commentInput.body = messageBodyInput;
18
19ConnectApi.Comment commentRep = ConnectApi.ChatterFeeds.postCommentToFeedElement(communityId, feedElementId, commentInput, null);