Pages

Sunday, August 4, 2013

Salesforce: Enable Feed Tracking versus Set History Tracking

A few months back, I wrote a blog on Chatter feed items and the structure, that blog explains "Feed Tracking" and the data structure. When selected fields are enabled for feed tracking, any changes to those fields will be shown in the record Feed. You can find this feed at top of the page layout,

If the user change value of more than 1 field in one update, it will be captured into only one feed (no matter how many fields are changed).



You can hide the feed by clicking the "Hide Feed" link or clicking "Fewer Updates" in Show: to show only the feed created manually (The feed automatically created by Feed Tracking will not be shown).

Feed Tracking is stored in an object, ending with the suffix Feed (for a Standard object) or __Feed (for a Custom object). If you dig further, records created by feed tracking will have API Type = TrackedChange, other value:
  • ContentPost - an uploaded file on a feed
  • LinkPost - a URL posting on a feed
  • PollPost - a poll posted on a feed
  • TextPost - a direct text entry on a feed
  • QuestionPost - a post as a question
You also can find the exact same value in the FeedItem object (with API version 23.0 or later).
SELECT Id, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Type, Parent.Name, Body,
(SELECT ID, FieldName, OldValue, NewValue FROM FeedTrackedChanges ORDER BY ID DESC)
FROM FeedItem
WHERE CreatedDate > LAST_MONTH
ORDER BY CreatedDate DESC

From the above query, you can see FeedTrackedChange is linked to the FeedItem object (using the FeedItemId field) and used to store the field name and old and new values. FeedTrackedChange object starts with the prefix 0D6 and FeedItem starts with the prefix 0D5. 


While for Set History Tracking from the object level, has almost the same function as feed tracking to track field change, but is stored in a different object and for the different purposes:

1. Record end with prefix History (for a Standard object) or __History (for a Custom object).

2. Every field change will have its own record in the history object and be directly linked to the ParentId.

3. The user can easily run a History report to display values change related to the object.



No comments:

Post a Comment