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
bvramkumarbvramkumar 

Reposting Chatter File to a Custom Object record on FeedItem Insert

Hi

 

I have a trigger on FeedItem that is responsible for reposting the chatter file to a respective record of a custom object based on the feed text entered by the user(User is expected to post from Home/Chatter tab). The way i am doing the reposting inside the trigger is... I am inserting a new feed item with parentId equals to the Id of the record to which i want this feed to be reposted(I have avoided the recursion there).

 

This trigger works for very small files (few KBs) but fails for bigger files. In case of large files, the reposting is happening(I can see the reposting happening in Debug Log), but the Original post insert which gets paused while reposting... fails. Can anyone please tell me why is it behaving this way? Please let me know if you did not understand my problem or need more explaination.

 

Thanks

Vishnu

Best Answer chosen by Admin (Salesforce Developers) 
bvramkumarbvramkumar

Hi

 

I found the solution myself.  Basically, Contentdata is stored in FeedItem object till it get uploaded. It will be stored in NewsFeed object once the uploading is done fully. There is a field called FeedPostId (which is deprecated and will not be available in future versions) which intern related to the FeedItem again.

 

So i changed the feed item trigger which was on before insert to after insert. After Insert, I will query newsfeed object by supplying feeditemIds(NewsFeed Ids are same as feeditem ids) and getting all the Chatter File(Content Data) bytes require. Then i will do the reposting to the custom object and delete the original feeds. It seemed that chatter data model is not so perfectly designed to me.

 

Thanks

Vishnu