Hello Everyone, In this tutorial, I am going to show you, how you can query deleted records from recycle bin in Salesforce. so without wasting the time let's get started,
Query deleted records in Salesforce
In some cases when performing a SOQL query, some records are not appearing in the query results because this query not included deleted and archived records. For example, Task more than a year old (365 days) are automatically disappear when we query data in Salesforce without using “ALL ROWS” keyword.
You can use ALL ROWS keyword in SOQL statements to query all records in an organization, including deleted records and archived activities.
Example:
List<Account> lstAccount=[SELECT Id,Name FROM Account ALL ROWS]; System.debug('^^^'+lstAccount);
Note: "ALL ROWS" keyword can’t
use with "FOR UPDATE" keyword.
See also:
Conclusion:
Hope you like this tutorial, for any query or suggestions
please feel free to comment.
Thank you.
4 Comments
Nice Blog, Thanks to share an amazing information with us, It helps me alot salesforce customer portal
ReplyDeleteThanks Steve
DeleteHi Manish, I was trying below query. It is giving me an error.
ReplyDeleteQuery: SELECT Id, isDeleted FROM Account WHERE isDeleted = true All ROWS
Error: Unknown error parsing query
Could you please let me know if I am missing anything.
Don't use "Query Editor", use anonymous window to execute the query.
DeleteList lstAccount=[SELECT Id,isDeleted FROM Account WHERE isDeleted = true ALL ROWS];
System.debug('^^^'+lstAccount);
Post a Comment