You need to sign in to do that
Don't have an account?
Retrieving field history of custom object through apex
Hi,
I am trying to retrieve history of field Salary at my custom object Employee. I am using the following query :-
List<Employee__c> lstEmp=[SELECT Id,Salary__c,
(SELECT OldValue,NewValue, FROM Histories)
FROM Employee__c
];
Now I need to retrieve a particular field only which is salary, I do not want other fields tracking details and I need to get date at which the change is made. Please let me know how should i modify my query and if you have the link to the documentation of history object present in salesforce please post that.
Thanks in advance....
Try this,
SELECT ParentId, OldValue, NewValue, Field, CreatedById, CreatedDate FROM Employee__History where parentId = :EmployeeId and Field = 'Salary__c'
hope this helps.
All Answers
Try this,
SELECT ParentId, OldValue, NewValue, Field, CreatedById, CreatedDate FROM Employee__History where parentId = :EmployeeId and Field = 'Salary__c'
hope this helps.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_leadhistory.htm
this might give you some idea.
if you open your schema in IDE or if you have force.com explorer, you can see the history object available for each standard/custom object