Wednesday, April 6, 2016

[Salesforce] The Sobject Crusade: AccountFeed

Back to the Sobject Crusade list.

Source: AccountFeed


This represents a single feed item on the Account record detail page (chatter feed).

It tracks different kind of feeds:

ActivityEvent—indirectly generated event when a user or the API adds a Task associated with a feed-enabled parent record (excluding email tasks on cases). Also occurs when a user or the API adds or updates a Task or Event associated with a case record (excluding email and call logging).

For a recurring Task with CaseFeed disabled, one event is generated for the series only. For a recurring Task with CaseFeed enabled, events are generated for the series and each occurrence.
  • AdvancedTextPost: created when a user posts a group announcement
  • ApprovalPost: generated when a user submits an approval
  • CanvasPost: a post made by a canvas app posts on a feed
  • CollaborationGroupCreated: generated when a user creates a public group
  • ContentPost: a post with an attached file
  • CreatedRecordEvent: generated when a user creates a record from the publisher
  • DashboardComponentAlert: generated when a dashboard metric or gauge exceeds a user-defined threshold
  • DashboardComponentSnapshot: created when a user posts a dashboard snapshot on a feed
  • LinkPost: a post with an attached URL
  • PollPost: a poll posted on a feed
  • ProfileSkillPost: generated when a skill is added to a user’s Chatter profile
  • QuestionPost: generated when a user posts a question
  • ReplyPost: generated when Chatter Answers posts a reply
  • RypplePost: generated when a user creates a Thanks badge in Work.com
  • TextPost: a direct text entry on a feed
  • TrackedChange: a change or group of changes to a tracked field
  • UserStatus: automatically generated when a user adds a post. Deprecated

To enable chatter feed tracking, go to Setup > Chatter > Feed Tracking and select the Account object and the fields you want to track.




Let's take this account:


We have an AccountFeed of type TrackedChange and another one of type TextPost.

By querying for AccountFeed:


Note that the query includes the subquery (SELECT Id, FieldName, NewValue FROM FeedTrackedChanges), that returns, only for the TrackedChange record:

[
    {
        "Id":"0D624000009RROlCAO",
        "FieldName":"Account.Phone",
        "NewValue":"(650) 450-8812"
    },{
        "Id":"0D624000009RROmCAO",
        "FieldName":"Account.Fax",
        "NewValue":"(650) 450-8822"
    }
]

which tracks the fields change that originated the AccountFeed record.

N.B. Note we could have used the FeedItem object as well:

SELECT id, Type, Title, Body, Visibility, likecount, NetworkScope, (Select Id, FieldName, NewValue From FeedTrackedChanges) from Feeditem where ParentId='00124000003vaBu'