Tuesday, February 21, 2023

Salesforce: Field History Tracking for Activities

Activity in Salesforce is represented by Task and Event objects, they are special objects with a few limitations compared to other standard and custom objects, one of them being field tracking.

Before the Spring '23 release, you can't track field changes in the Activity, with community members creating and voting this in IdeaExchange that earned 33000+ votes.

The spring '23 release allows us to track activities fields history, with some limitations, but it is definitely a good starting. 

Navigate to the Task or Event object and click the "Set History Tracking" button and select up to 6 fields.

You can add the Activity Record History component from Lightning App Builder.



Here is the sample result in a Task:



Unfortunately, I don't see this yet in reporting, hope this will come in coming releases, or let me know if you see this. But you can query with API to object ActivityFieldHistory.

sample query: SELECT Id, ActivityId, ChangedBy.Name, FieldName, OldValueText, NewValueText  FROM ActivityFieldHistory 

I have no idea why the Ids are 000000000000000AAA, hope will see some explanation in the future.


For more information, looks for Event and Task History Considerations in this article Field History Tracking (as per Spring 23 release):

  • It can take up to a few minutes for changes to appear in history.
  • You can track up to six fields on events or tasks.
  • After an activity is deleted, the history for the activities can be visible via API queries for up to a few days. The history remains available because it’s deleted asynchronously from the activity.
  • Not all changes to recurring and child events are tracked.
  • You can’t delete specific field history records.
  • Bulk processes such as Bulk API transactions or event syncing can be delayed when field history tracking is enabled. If processes are delayed, consider turning off activity field history tracking.
  • The parent record of an activity is locked when the activity history updates. For example, if an activity is linked to thousands of accounts, each account is locked while the history updates. As a best practice, avoid data skew. If processes fail because of parent-child row locking, consider turning off activity field history tracking.
  • Field value changes caused by process builder, Apex triggers, or flows are tracked in an activity’s history. Users see the change only if their field-level security settings permit them to. In other objects, field changes from processes, triggers, and flows are tracked only if the current user has permission to edit the modified fields.
  • If a previously encrypted field used for tracking is unencrypted, the values tracked while the field was encrypted don’t appear. After the field is unencrypted, the values are tracked in history.
  • Activity history is available in APIs only for admins with permission to modify all data.
  • For activities, field history is shown in a Lightning component that looks like a related list. Instead of managing the history on the page layout, you place the Activity Record History component on Lightning pages for event and task records. You can add the Activity Record History component to custom event and task pages or remove it from the default pages. The history list stays empty until you turn on field history tracking in the Object Manager.
  • The history list isn’t available in Salesforce Classic or in the mobile app.


Reference:

No comments:

Post a Comment

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC)

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC) Introduction: Salesforce Lightning Web ...