You need to sign in to do that
Don't have an account?

Delete those student records permanently from your salesforce org who have second letter ‘R’ in their names
List<Student__c>obj1 = [Select Name,Student_Name__c From Student__c Where Student_Name__c Like '_r%' And
isDeleted = true All Rows];
Database.emptyRecycleBin(obj1);
isDeleted = true All Rows];
Database.emptyRecycleBin(obj1);
I tried something like this and it initially threw me the same error message you posted when there are no deleted records.
List<Account> a=[Select id,Name From Account Where Name Like '_r%' and isDeleted=true ALL ROWS];
system.debug(a+'===');
Database.emptyRecycleBin(a);
system.debug(a+'===');
However, after deleting a record that satisfied the SOQL condition , and running this same code in the dev console, it ran without error message showing the deleted record in system.debug.
I believe there were no records to be deleted from recyclebin which caused the error.Can you check the recycle bin and confirm?
Thank you
All Answers
Can you share more details on your ask? Are you seeing any error? Thanks
I tried something like this and it initially threw me the same error message you posted when there are no deleted records.
List<Account> a=[Select id,Name From Account Where Name Like '_r%' and isDeleted=true ALL ROWS];
system.debug(a+'===');
Database.emptyRecycleBin(a);
system.debug(a+'===');
However, after deleting a record that satisfied the SOQL condition , and running this same code in the dev console, it ran without error message showing the deleted record in system.debug.
I believe there were no records to be deleted from recyclebin which caused the error.Can you check the recycle bin and confirm?
Thank you