1

I am new to salesforce, please help me out with this one: I am trying the following SOQL query to retrieve the changes made to the teacher object but I am getting nothing in the history tab.

I turned in History tracking for that object and checked the required fields.

SELECT name, teacher_name__c, (SELECT oldValue, newValue FROM Histories) 
FROM teacher__c
2
  • The reason it is empty is that nothing is put there. Nothing is put there because history does not work for your object. Before having records in history you need to turn on the feature, select fields you want to track, make a change on a record. – Andrii Muzychuk Apr 5 at 14:17
  • if you are doing this in a testmethod, you can't - history records are never added in testmethods – cropredy Apr 6 at 1:30
2

You would need to enable 'Track Field History checkbox' under object settings. Select Object Manager--> Click the custom object (Teacher__c) and click Edit--->Under Optional Features, select the Track Field History checkbox.

enter image description here

Later add Custom object History (Teacher__c) related list on the detail page or you can run above query to check 'New Value' and 'Original Value'.

Review more details here.

Thanks

1
  • You missed one critical step - Choose the fields you want tracked. – Andrii Muzychuk Apr 5 at 14:16
-1

Please check if you have enable the same field for field history tracking

1   From Setup, click Object Manager and select Teacher__c
2   Select Fields & Relationships, and click Set History Tracking.
3   Select Enable Teacher History, then select these two fields to track: teacher_name__c
4   Click Save.
2
  • Thank you for you reply.Yes, I have. – abhishek0514 Apr 4 at 11:51
  • It is working fine for Standard Object. It is not working fine for custom objects. – abhishek0514 Apr 4 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.