Play Games

Search This Blog

Friday, May 17, 2019

How to query field history of a particular field of an object Salesforce.

Assume we need to query history of status__c field of Suggestion__c object.

Also assume 'a0H0o00000iFDkU' is the id of the suggestion record created.

required SOQL will be as follows.

List<Suggestion__c> lstSuggestion = [SELECT Name, Status__c  , (SELECT OldValue, NewValue FROM Histories where field='Status__c')
FROM Suggestion__c  where id=:'a0H0o00000iFDkU'];
system.debug('Suggestion Status Field History:'+lstSuggestion[0].Histories);

Output:


No comments:

Post a Comment