Tuesday, May 31, 2016

APEX: Access History Programatically

For Standard Objects:
AccountHistory
ContactHistory
OpportunityHistory

For Custom Objects:
MyCustomObject__History

Example:
1. Select Id, Name, (Select OldValue, NewValue From Histories) From MyObject__c [1]

2. Select ParentId, OldValue, NewValue, Field, CreatedById, CreatedDate From MyObject__History [2]

[1] http://salesforce.stackexchange.com/questions/17057/how-to-track-history-of-a-record-of-a-custom-object-in-apex-classhttp://salesforce.stackexchange.com/questions/17057/how-to-track-history-of-a-record-of-a-custom-object-in-apex-class

[2] https://developer.salesforce.com/forums/?id=906F0000000937RIAQ

No comments:

Post a Comment