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
anvesh@force.comanvesh@force.com 

how to get the recent deleted records using query?

how to get the recent deleted records using query?

Best Answer chosen by Admin (Salesforce Developers) 
imutsavimutsav
Every Object in SFDC has isDeleted field. This is a Boolean field. If you write a query on this with filter where isDeleted=TRUE then you would only get deleted records.

Eg.

DateTime deletedDt = Datetime.now();

Account[] acctLists =
[SELECT Id, Name FROM Account
WHERE LASTMODIFIEDDATE<:deletedDt AND IsDeleted = TRUE ALL ROWS];

use the Lastmodifieddate to refine your filter.

Thanks
Utsav

[Do mark this answer as solution if it works for you and give a kudos.]