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
Jon SheaJon Shea 

FeedComments posted to Parent Record ?


I have a trigger that currently creates a chatter FeedItem and posts to the Parent record on certain conditions. Now I am being asked to also make sure any comments made on the FeedItem in the Child record are also posted to the duplicate post on the Parent record. (basically duplicating the comments and making sure they are posted in both places. ) The goal here is for people to be able to follow only parent records (let's say Accounts) - and receive all child record posts and comments under the Parent record. 

I'm able to create the individual posts - but can't figure out how to map comments from the child record FeedItem to the correct Parent record FeedItem.

Since there are two FeedItemIDs (one on child, one on parent) how can I find the correct FeedItem Id on the parent record - assuming each Parent record has multiple feed items ? 


I don't think there is a way directly via the FeedItem.  I think you'd have to take the FeedItem, get it's ParentId.  Then query for it's Parent (ie Contact) and then get that record's Parent (ie Account) and then create your FeedItem.