How do I query custom object history in SOQL with an inner query?

I’m trying to pull the history records of a custom object with an inner query.

Here is the sample:

Select Id, Name, (Select NewValue From Custom_Object__History) From Custom_Object__c

Based on the documentation here

This should work.

example in documentation:

SELECT Name, customfield__c, (SELECT OldValue, NewValue FROM foo__history)FROM foo__c

Any help is appreciated.

Thanks,

Answer

Child history table name is common and is “histories”,
This SOQL should work :

Select Id, Name, (Select NewValue From Histories) From Custom_Object__c

Attribution
Source : Link , Question Author : Jonathan Jenkins , Answer Author : Abhinav Gupta

Leave a Comment