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
MotokiMotoki 

How to following a Chatter file in Apex

Hi guys,

 

I was wondering how do you following a Chatter uploaded file in apex code please? i know how to following a record or a user or how to copy a record FeedItem into another record but i'm not so sure how different it is to follow a file so the user who is already following that record gets the updates for the file as well...

 

Any information would be great help.

 

Thank you very much for your help in advance.

Best Regards,

Motoki

MotokiMotoki

Hello, not even one person knows if it is possible to follow a file via Apex code?

MotokiMotoki

Thanks for your reply. I just did a query on the ContentVersion and ContentDocument objects in my schema browser and i can't find any reference to my chatter file at all... However, i did found the file in the FeedPost object that belongs to my custom object feed. Apex doesn't let me put a FeedPostId in EntitySubscription's parentId field...

 

Is there any chance it is stored in another object?

 

Best Regards,

Motoki

jkucerajkucera

I'm not sure why the file didn't appear in the query for ContentVersionId nor ContentDocument as it should be in both of them.  

 

The first 3 characters of ContentDocumentId should be "069" as all files start with that index - that might help you make sure you hvae the correct Id. 

 

The FeedPostId won't work as that's no thte Id of the file, but rather that of the post itself.  

 

Note in 2 weeks (mid June, 2011), the files team is exposing ContentDocumentId on FeedPost so you can Insert new FeedPosts referencing existing files.  Today, that is not possible.