Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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)

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

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.

share|improve this answer
    
Thank you so much for the clarification. I think I will go with the first and preferred solution you suggested. –  Vishal Feb 1 '13 at 9:54
    
To make it easier to get back to the record, you can always include a link back to the record in you second feed item when you post to the group. When (safe harbor) Apex Connect for Chatter goes GA, you can even make it a link post. I'd be curious to know the underlying mechanism for sharing a post through the UI. If you could tap into that, it would be the best way. –  Peter Feb 1 '13 at 14:28
add comment

Agree with zachelrath, but as an alternative you might try posting to your group's feed, and put the link to your record in the post LinkURL, body or perhaps in a comment. So now the single post is related to the group and (loosely) to the record. The post will of course not appear in the record's feed. However, you were suggesting using VF to render the posts on the detail page for the record. Using the new Connect in Apex classes, you may well be able to search for and render the posts related to a record on a VF page by searching for the record ID (this isn't something I have tested).

share|improve this answer
    
This sounds interesting. I haven't explored the Connect feature in Apex Classes either. Thanks for the suggestion, I'll give it a try and let you know if it helps. –  Vishal Feb 1 '13 at 12:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.