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
SF Beginner 2019SF Beginner 2019 

delete account that is not changing status for 90 days

Hi All,

I am creating a batch job wherein should delete if the account if status is not changed for last 90 days when it was created, other wise if there is change for the last 90 days don't delete can you help me on how to do it, basically from the account object history, since it has only new value, old value and created date?

thank you

 
ANUTEJANUTEJ (Salesforce Developers) 
Hi there,

One possible way is to have a field track the status of the field and you can have a scheduled apex class that runs at a particular time every day and calls the batch class which can fetch the records where the status is not changed for last 90 days and delete them.

To track the status you can check this link: https://salesforcesidekick.com/2016/04/11/how-to-track-the-age-of-each-status/

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.