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
Matthias GuentherMatthias Guenther 

Cast FeedItem to a ConnectApi.FeedItem

Hi:
Just getting familiar with the ConnectAPI.

I want to repost a file to a parent object. I have a Trigger on FeedItem, is there a way to create a ConnectApi.FeedElement / ConnectApi.FeedItem form a FeedItem with the ConnectAPI?

Thanks
alouie_sfdcalouie_sfdc
One option is to use the ConnectApi.ChatterFeeds.shareFeedElement() method. It accomplishes the same thing as the "Share" link in the Salesforce UI. The documentation is here:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_ConnectAPI_ChatterFeeds_static_methods.htm#apex_ConnectAPI_ChatterFeeds_shareFeedElement

From a trigger, just use the ID of your FeedItem as the originalFeedElementId.