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
Barkha Rathi 7Barkha Rathi 7 

Hi All, how can I get deleted date of a record from Recycle bin using SQL in apex?

Hi All, how can I get deleted date of a record from Recycle bin using SQL in apex?
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Barkha,

Yes you can retrive it if you know some details about the record like name or id .. etc. You just need to refer lastmodifieddate field like below.
 
List<Account> acclist=[SELECT Id, Name,LastmodifiedDate FROM Account WHERE Name = '5777883422dad' ALL ROWS];
system.debug('sass'+acclist);

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,

 
Vineela ProddaturuVineela Proddaturu
Hi Barkha,

Please, try this one.

List<opportunity> deletedOpps =  [select id, name from opportunity where isDeleted = true and Id = '<RecordIdGoesHere>' ALL ROWS];
system.debug(deletedOpps);

If, it helps. Pls, mark it as best answer.
 
Thank you.