function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KSusan CoxKSusan Cox 

Fetch file name and extention in FeedComment.

Hi,

          Is there any option to fetch file name and  extention in FeedComment SObject. I am trying to fetch the name and  extention to block file.

      So any one know the solution. Please let me know ASAP.

Thanks
Best Answer chosen by KSusan Cox
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
For comments with files attached we have RelatedRecordId field which holds the releted content.
you can get RelatedRecordId as
FeedComment oFeedComment = [SELECT Id, CommentBody,CommentType,FeedItemId,ParentId,RelatedRecordId FROM FeedComment limit 1];

Id sReletedRecordId = oFeedComment.RelatedRecordId;

ContentVersion  oContent = [SELECT FileType,Title FROM ContentVersion where id = :sReletedRecordId];
This example shows how to get filetype and filename for single feedcomment which has an attachement.

Hope this will help.
If this answers your question, mark this as best answer.
-N.J

All Answers

Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
For comments with files attached we have RelatedRecordId field which holds the releted content.
you can get RelatedRecordId as
FeedComment oFeedComment = [SELECT Id, CommentBody,CommentType,FeedItemId,ParentId,RelatedRecordId FROM FeedComment limit 1];

Id sReletedRecordId = oFeedComment.RelatedRecordId;

ContentVersion  oContent = [SELECT FileType,Title FROM ContentVersion where id = :sReletedRecordId];
This example shows how to get filetype and filename for single feedcomment which has an attachement.

Hope this will help.
If this answers your question, mark this as best answer.
-N.J
This was selected as the best answer
KSusan CoxKSusan Cox
 Hi N.J,

Thanks for the suggestion. I tried it but it is not working. And I also test filetype of contentVersion but it is not fetching extention. It shows null value.

So please give me another solution.

Thanks.