I'm trying to fetch opportunity records whose field(StageName) has been changed in the past 24 hours and whose child record(Say="Some X OBject", it's a masterdetail relationship) has field called 'status'=approved?
How can I fetch these records in the start
method of a batch class?
I've tried:
List<Id> OppIds= new List<Id>();
for (Invoice__C Inv:[select id,name from Invoice__C where status__C='Approved']) {
OppIds.add(Inv.Opportunity__c);
}
DateTime Past24 = system.now().AddDays(-1);
return Database.getQueryLocator([select id from Opportunity where LastModifiedDate > :Past24 and Sent_to_ShareDo__c=false and Id IN :OppIds ]);