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
kjpetersonkjpeterson 

Linking to ContentPost file from custom chatter feed

I'm creating a custom chatter feed using visualforce and apex.  I can't find the value for the fileid that a contentpost created.  In the standard chatter feed if I click on the file title it sends me to a page showing the file and it appears to link to just the salesforce file id.  Can I get this id too?  I'm just wanting to give users an easy way to go to the file.

cloudcodercloudcoder

If I am following you correctly, Spring 11 is your friend!

 

A new entity, ContentDocumentLink has been added to the Chatter Data Model to allow you to access files uploaded via Chatter. Try something like this:

 

 

SELECT id, LinkedEntityId, ContentDocumentId
FROM ContentDocumentLink 
WHERE LinkedEntityId = '<my-entity-id>’

 

 

kjpetersonkjpeterson

Could I get this info in a single Feed query where I already have subqueries for FeedTrackedChanges and FeedComments?

cloudcodercloudcoder

No. You will need to do it as a separate query as the *Feed entity does not have a relationship with the ContentDocumentLink entity