+ Start a Discussion
Yaari VidanpeledYaari Vidanpeled 

How do I retrieve data after setting Field History

Hello,

I am a newbie to Salesforce. After setting up Field History for Opportunities Object I wish to retrieve data for a specific field eg. `Account Name`. Can I have an example regarding how this can be done.
Thank you in advance for any  help rendered 
OFröhlichOFröhlich
Hi,

go Setup - Object Manager - Fields & Relationships - Set History Tracking (upper right corner)
Choose Account Name as a field to track. If you change the value, you will see the changes in the history related list.

If this helps, please mark as Best Answer to help others too.
VinayVinay (Salesforce Developers) 
Hi Yaari,

You can export field history data using Data Loader.

Review below link for same.
https://help.salesforce.com/articleView?id=000318128&language=en_US&type=1&mode=1

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
Yaari VidanpeledYaari Vidanpeled
I was able to retrieve the data using the Developers console --> Query Editor

My query looked like this:
SELECT CreatedById, CreatedDate, Field, Id, IsDeleted, NewValue, OldValue, OpportunityId FROM OpportunityFieldHistory

But I wish to Inner Join the data with the Name field in Opportunity. If it was a regualar inner join query I would use something along the lines of:

SELECT a.CreatedById, a.CreatedDate, a.Field, a.Id, a.IsDeleted, a.NewValue, a.OldValue, a.OpportunityId FROM OpportunityFieldHistory a, b.Name INNER JOIN Opportunity b ON a.OpportunityId=b.Id

That did not work unfortunatly. Then I tried the following Query

SELECT CreatedById, CreatedDate, Field, Id, IsDeleted, NewValue, OldValue, OpportunityId FROM OpportunityFieldHistory  WHERE OpportunityId in (SELECT Name FROM Opportunity)

Please Help!!!!
VinayVinay (Salesforce Developers) 
You are using inner query in where clause to get the list of ids but you are fetching the name.

Try to use below query.

SELECT CreatedById, CreatedDate, Field, Id, IsDeleted, NewValue, OldValue, OpportunityId FROM OpportunityFieldHistory  WHERE OpportunityId in (SELECT id FROM Opportunity) .

Thanks,
Vinay Kumar
Yaari VidanpeledYaari Vidanpeled
Hi Vinay. Thank you for taking the trouble to help me.
I actually need the name from Opportunity and I have the Id of the record which is the value of OpportunityId.

Thanks,
Yaary Vidanpeled