You need to sign in to do that
Don't have an account?

SOQL issue: not retrieving old and new value
Hello
I have a custom object for which I want to retrieve some field history.
For this I use the following SOQL query:
SELECT Field,NewValue,OldValue FROM Car__History
But it only pulls out the Field names, not the Old and New values, any ideas?
Thanks
If you can see it, you can query it in Execute Anonymous in Eclipse or Developer Console.
But you can't see the new/old value in the SOQL query window in salesforce.schema of Eclipse.
All Answers
1. in the Custom Fields & Relationships, click 'Set History Tracking',
make sure which one you are tracking
2. in the Record detail page, click Edit Layout, in the Related Lists, add History to the page,
3. Then you will see the Tracked Changes on the Record page, and also you can query it by Apex
Hello Jia
I have done all you have mentioned (it was arleady done actually).
It doesn't work, when I do my SOQL query, I do get rows for each track change but not the "old value" and "new value".
Marc
If you can see it, you can query it in Execute Anonymous in Eclipse or Developer Console.
But you can't see the new/old value in the SOQL query window in salesforce.schema of Eclipse.
Thanks Jia
I tried in Anonymous Block and also Data Loader, both worked.
I was originally using workbench: https://workbench.developerforce.com/
I think it is a just a limitation of this tool specifically.
I too am having trouble getting APEX access to OldValue, NewValue. I'll keep you posted. One thing I do notice in my Data Loader extract is that when the Field is a Multi Select Pick List, I don't see the values.
Further the code that I'm writing seems to choke when I assign the contents of OldValue, NewValue to a variable - as I read it, OldValue, NewValue is "Any Type" - meaning they take on the type of the Field in question.
I can't imagine no one is using History within APEX to do useful processing!
Solution found here:
http://boards.developerforce.com/t5/Apex-Code-Development/Is-there-a-small-code-example-of-using-History-s-OldValue-or/td-p/493999
Use the valueOf method.