Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Attachment myAttachment =[SELECT Id, Name,Body,Description,ContentType FROM Attachment where Id =:myFile.Attachment_ID__c];
- String communityId = 'myCommunityId';
- // CREATE A FEED_ITEM_TEXT
- ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput();
- messageInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
- ConnectApi.TextSegmentInput textSegment = new ConnectApi.TextSegmentInput();
- textSegment.text = shareComment;
- messageInput.messageSegments.add(textSegment);
- ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput();
- input.body = messageInput;
- // POST FILE_FEED_ITEM
- ConnectApi.NewFileAttachmentInput fileIn = new ConnectApi.NewFileAttachmentInput();
- fileIn.title = fetchDigitalChatterFile.Attachment_Name__c;
- input.attachment = fileIn;
- Blob userFile = myAttachment.Body;
- ConnectApi.BinaryInput feedBinary = new ConnectApi.BinaryInput(userFile,myAttachment.ContentType,myAttachment.name);
- // PARAMETERS(communityId, feedType, subjectId, input,filebody);
- ConnectApi.FeedItem feadItem = ConnectApi.ChatterFeeds.postFeedItem(communityId, ConnectApi.FeedType.Record,'share To Id',input,feedBinary);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement