既存のファイルを添付したコメントの投稿
コメントを投稿し、既存のファイル (Salesforce にアップロード済み) をコメントに添付するには、ConnectApi.CommentInput オブジェクトを作成してpostCommentToFeedElement(communityId, feedElementId, comment, feedElementFileUpload)メソッドに渡します。
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17String feedElementId = '0D5D0000000KtW3';
18
19ConnectApi.CommentInput commentInput = new ConnectApi.CommentInput();
20
21ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
22ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
23
24textSegmentInput.text = 'I attached this file from Salesforce Files.';
25
26messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
27messageBodyInput.messageSegments.add(textSegmentInput);
28commentInput.body = messageBodyInput;
29
30ConnectApi.CommentCapabilitiesInput commentCapabilitiesInput = new ConnectApi.CommentCapabilitiesInput();
31ConnectApi.ContentCapabilityInput contentCapabilityInput = new ConnectApi.ContentCapabilityInput();
32
33commentCapabilitiesInput.content = contentCapabilityInput;
34contentCapabilityInput.contentDocumentId = '069D00000001rNJ';
35
36commentInput.capabilities = commentCapabilitiesInput;
37
38ConnectApi.Comment commentRep = ConnectApi.ChatterFeeds.postCommentToFeedElement(Network.getNetworkId(), feedElementId, commentInput, null);
39
40