Showing posts with label History. Show all posts
Showing posts with label History. Show all posts

Tuesday, April 26, 2016

[Salesforce] The Sobject Crusade: ActivityHistory

Back to the Sobject Crusade list.

Source: ActivityHistory

The ActivityHistory object is a read-only object that shows all completed Tasks and past Events related to a give object (e.g. Account). It includes activities for all contacts related to the object.

This object is shown in the Activity History related list:


Few limitations apply:

  • The object cannot be queried directly but only queried through inner query (e.g. Select Id, (Select Subject From ActivityHistory) From Account Where Name = 'ACME bros')
  • Your main query must reference exactly 1 record
  • Inner query must not have a WHERE clause
  • Inner query must filter a maximum of 500 items

Here is an example query:
SELECT Name, (SELECT ActivityDate, Subject, IsTask FROM ActivityHistories ORDER BY ActivityDate ASC NULLS LAST Limit 500) FROM Account WHERE Name ='ACME Bros'

Friday, April 8, 2016

[Salesforce] The Sobject Crusade: AccountHistory

Back to the Sobject Crusade list.

Source: AccountHistory

This object supports Field Tracking History on the Account object.

To track fields on the Account object, go to Setup > Accounts > Fields and click the Set History Tracking button.

Then click on the Enable Account History flag and select all fields to be tracked:




From now on the selected fields will be tracked in the Account History related list:


Here is the corresponding query:

Select Id, Field, NewValue, OldValue From AccountHistory Where AccountId = '00124000003vaBu'


History tracking has few limitations:
  • You can track upto 20 standard and custom fields per custom object
  • The field history data is retained for up to 18 months
  • Changes to fields with more than 255 characters are tracked as edited, and their old and new values are not recorded
  • Tracked field values are not automatically translated
  • Changes to custom field labels that have been translated via the Translation Workbench are shown in the locale of the user viewing the History related list
  • Changes to date fields, number fields, and standard fields are shown in the locale of the user viewing the History related list
  • If a trigger causes a change on an object the current user doesn’t have permission to edit, that change is not tracked because field history honors the permissions of the current user
  • Additional field history increases beyond your current limits require the purchase of the Field Audit Trail add-on, following the Spring '15 release