Feed-Tracked Changes

Feed-tracked changes provide an audit trail of modifications to a set of fields. For each record in an object that has feed-tracked changes enabled, there can be many corresponding feed-tracked change records. Each change record captures the original field value, the new field value, the field name, and the new and old currencies if multicurrency is enabled in the organization and the field is a currency type.

The change records for all objects in an organization with feed-tracked changes enabled are stored in a single object called FeedTrackedChange. The schema pattern for this object is illustrated in Figure 12.3.

Image

Figure 12.3 Chatter feed-tracked changes schema pattern

FeedTrackedChange cannot be queried or modified in any way by any user, even an administrator. Like Chatter comments, it must be queried indirectly via its junction object. Listing 12.9 shows an example of querying all posts on Contact records and their corresponding FeedTrackedChange records.

Listing 12.9 Querying Chatter Feed-Tracked Changes


SELECT ParentId, Type, CreatedById, CreatedDate,
  (SELECT FeedItemId, FieldName, OldValue, NewValue
    FROM FeedTrackedChanges)
  FROM ContactFeed


To see the query in action, enable feed-tracked changes on the Contact Phone field; then change the Phone value on a record and run the query. You should see a new record with a Type value of TrackedChange containing a nested FeedTrackedChange record. The nested record has the old and new Phone values along with the full field name, Contact.Phone. Had you changed two feed-tracked change fields within the same transaction, you would see two nested FeedTrackedChange records instead of one.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.192.92