[SalesForce] A Chatter Feed related to a Record as well as a Chatter Group

I have a business case where currently we post chatter feeds to a Chatter Group using Apex. This is done by assigning the CollaborationGroup (chatter Group) Id to the ParentId field on the FeedItem.

Each of this post is generated when a Record is created. So it is related to a record as well.
However since the ParentId field has Group Id, it does not reflect on the record's chatter. (this is fine)

Now, we need to have a custom visualforce related list on the Record detail page where we'll be showing the Chatter feeds related to the particular record. Since the feeds we generate are been assigned to the Chatter group, there is no way we can identify which record each feed is related to.

Is there any direct solution to assign a feed to a record and also show it in a Group? Or would I need to have two feeds – one for the group and one for the record. (I hope this isn't the case)

Best Answer

Each Chatter FeedItem can only have one parent record - and if you'd like these FeedItems to show up in a record's chatter feed, e.g. using <chatter:feed entityId="{!recordId}"/>, then you'll have to have the record be the parent of the FeedItem. So, to be able to accomplish your intention - of having a record show up in both the Record's feed and a Group's feed, here are some thoughts on how to achieve this.

  1. (Probably the best way) Create 2 FeedItems with the same content, one whose ParentId is the Record, and one whose ParentId is the CollaborationGroup.
  2. (If you must post just one FeedItem, and have to post it to the CollaborationGroup): on your Visualforce page, instead of showing a <chatter:feed>, which will just show just Chatter related to that record, you could use the <chatter:newsFeed> tag instead. This will show all Chatter relevant for the running user. That way, if the running User is a member of the CollaborationGroup to which you posted the FeedItem, the running User will, when viewing this Visualforce page, see the recent Chatter posts for the CollaborationGroup, as well as any Chatter posts for the record in context, or Chatter posts directed at them.

  3. (If you must post just one FeedItem, and you can post it to the Record) If you can post the FeedItem to the Record, but don't want to create a duplicate FeedItem in the CollaborationGroup, but you still want all members of the CollaborationGroup to be updated when these FeedItems are posted to the Records in question, you could leverage / create Auto-Follow Rules (whether built on your own with Triggers or through one of the AppExchange apps that does this) to have all members of certain CollaborationGroups automatically follow these Records - that way, in their Chatter Feeds, they'll be guaranteed to see all of the FeedItem posts in question. Alternatively, you could have all followers of the Record automatically made members of the CollaborationGroup - depends on your situation.

Related Topic