+ Start a Discussion
PremInfoPremInfo 

Attaching Files to Comment

Hi,

 

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

 

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

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_feedcomment.htm

 

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.
PremInfoPremInfo

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,

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_contentversion.htm
PremInfoPremInfo

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.

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_contentdocument.htm