+ Start a Discussion

Attaching Files to Comment



Is it possible to upload / download a file from the FeedComment using SOQL. 


FeedComment object is not having any fields to hold the attachments.




Kindly let me know the workaround for the same.

Jia HuJia Hu
Basically, you can do it, but it has some limits.

For example,
FeedComment fc = new FeedComment();
fc.FeedItemId = '0D5O0000001cfMb';
fc.CommentBody = 'test';
fc.RelatedRecordId = '068O00000006aIO';
insert fc;

you can only upload to comment through a existing file id(ContentVersion id), also you can download the file by this id.

Thanks I am able to upload the attachment using the RelatedRecordId. Kindly let me know how to download the same.

Do I need query differently? I am using SOQL for my app.

Jia HuJia Hu
Yes, you have to use the RelatedRecordId to query the ContentVersion object to get the file,


Thanks, I am able to query at ContentVersion and get the VersionData. I need to find out the name of the file attached also to download to my local system. In the contentVersion object there is no any field to get the name of the file attached. Do I need to refere any other object for the ContentName.



Jia HuJia Hu
Get the ContentDocumentId field on the ContentVersion object and query the ContentDocument object to get the Title field of the file.