Pages

Wednesday, March 20, 2013

Query Chatter Feed Item & How the structure in Salesforce object


Salesforce admin can enable Chatter feed tracking on Salesforce objects, including custom objects.
Go to Setup and search for Feed Tracking in the Quick Find search box. Select the object to track and tick "Enable Feed Tracking", you can select up to 20 fields.

In the background, once an object is enabled for feed tracking, Salesforce will create a new object with the suffix Feed (for Standard object) or _Feed (for Custom object). This is available in API version 18.0 and later.

Sample query:
SELECT Id, ParentId, Type, RelatedRecordId, Title, Body, CreatedById, CreatedDate, CommentCount, LikeCount FROM AccountFeed ORDER BY CreatedDate DESC
This query will return all feed tagged to Account (see ParentId field)

Another object storing all feeds is FeedItem, this object is available in API version 21.0 and later, sample query
SELECT Id, ParentId, Type, RelatedRecordId, Title, Body, CommentCount, LikeCount FROM FeedItem ORDER BY ParentId
This query will return all feed tags to any objects.

See the architecture below (right-click the image to enlarge):


Notice that objectFeed object shared the same prefix with FeedItem: 0D5

If you need the screenshot in Visio file, click here


8 comments:

  1. Could u help on this issue plz

    http://boards.developerforce.com/t5/Chatter-and-Chatter-API/Updating-a-Chatter-FeedItem/td-p/705923

    ReplyDelete
    Replies
    1. Harpit, here is my analysis:
      - Everytime a record created in FeedItem, it will create a new record automatically in ContentVersion and ContentDocument
      - See RelatedRecordId field in FeedItem
      - When upload new version for FeedItem, create new record in FeedItem with
      * Type = TrackedChange
      * ParentId = ContentDocument

      Play around with it and let me know if you can solved it.

      Delete
  2. Hi Johan,
    Have posted my reply on
    http://boards.developerforce.com/t5/Chatter-and-Chatter-API/Updating-a-Chatter-FeedItem/m-p/706647/highlight/false#M3357

    Please have a look and let me know your thoughts.

    Cheers,
    H

    ReplyDelete
  3. Can I migrate feed Views count and feed Likes/upvotes from one org to another? I see that FeedLike and FeedSignal Objects cannot be queried

    ReplyDelete
  4. I keep getting a malformed query error when querying FeedItem:

    MALFORMED_QUERY: Implementation restriction: FeedItem requires a filter by Id

    EVen if I put a where condition with an id filter

    ReplyDelete
  5. Can I get viewCount from Chatterfeed in apex?

    ReplyDelete