You need to sign in to do that
Don't have an account?
George Liang 3
SOQL Query to Pull Field that has not been modified for the last 21 days
In Opportunity, I have a field called Status__c. I want to pull a list of records in which Status__c specifically has not been updated in the last 21 days. History tracking has been turned on for that field over a year ago. What's the SOQL query to do so?
Below is a proto type I haven't tested the same. I hope below code works for your Business Case.
Create a field called "Status_Last_Updated__c"
Execute below logic.
In you organization if you have more than 10000 records. Try to update the record in chuncks by executing the above logic with below main query.
Once you are done updating the field Status_Last_Updated__c.
Define process using process build :
update the field Status_Last_Updated__c value "now" whenever the record created or The status field updated to new value.
Please try this:
Select Id, name from opportunity where id in (SELECT OpportunityId FROM OpportunityFieldHistory where field = 'Status__c' and createdDate < LAST_N_DAYS:21)
Thanks,
Ankit