function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
enossirenossir 

comparing data from soql query

I'm trying to compare data from querys on two different objects.

Object 1: Opportunity

Object 2: OpportunityFieldHistory

Now object 2 has the 'OpportunityId' field which matches up with, you guessed it, the opportunity object Id field. So what I'm trying to do is 

Pull information on two fields from the opportunity Object, these two fields would have been modified so the data in them is not null (as an AND statement not OR i need them both to be not null). Now i want to fix the modifications made to those fields within around 800 or so opportunities. 

Thats where the field history comes in. It has the Old data that i want, but i need to pull the correct opportunities ID's out and then cross reference them with a set from the field history and fitler out the field history data i actually want.

sooo

healp me please
enossirenossir
Select op.Id, op.Name, op.Install_Date__c, op.PPM_Scheduled_Go_Live_Date__c, (SELECT Id, Field, OldValue, NewValue, OpportunityId FROM OpportunityFieldHistory) FROM Opportunity op WHERE PPM_Scheduled_Go_live_Change_Count__c != 'null' AND PPM_Scheduled_Go_live_Change_Count__c != '' AND Boolean_check_install_date__c = TRUE

I'm thinking that might work...I'd rather go SOQL only as i'm trying to get this data from data loader and export it into a csv
enossirenossir
But then i get this


Didn't understand relationship 'OpportunityFieldHistory' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Raj VakatiRaj Vakati
Do you have history tracking enabled on the Opportunity ? once you enabled the Opportunity Field History tracking then only you can able to query OpportunityFieldHistory ..


https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/tracking_field_history_for_standard_objects.htm