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
new sivanew siva 

fetching opportunities for which Child 'Invoice' has been created or updated with Status=Approved in the last 24 hours

HI all , please help me with the following.

Suggest how can i fetch opportunities for which Child record 'Invoice' with Status=Approved was created in the last 24 hours without using rollup summary. I'm fetching these in a batch class
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Siva,
 
public Database.QueryLocator start(Database.BatchableContext context)
{
    return [
        SELECT ... FROM Opportunity
        WHERE Approved_Child_Count__c > 0
        AND Id IN (
            SELECT OpportunityId FROM OpportunityFieldHistory
            WHERE Field = 'Stage' AND CreatedDate >= YESTERDAY
        )
    ];
}

Please refer the below link for reference for similar kind of issues. http://salesforce.stackexchange.com/questions/167516/query-opportunities-whose-field-has-been-changed-in-the-past-24-hours

I hope it will be hopeful.

Please mark it as best answer if the information is informative.

Best Regards
Rahul Kumar