One way to delete using Developer Console is to first execute your query SELECT Id, Subject, Status from Case Then highlight all the result rows and click on the Delete Row button at the bottom.
Another way to delete multiple cases is through Mass Delete Records. Go to Setup -> Quick Find -> Mass Delete Records -> Mass Delete Cases -> Search
You can also create a Visualforce page. Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
public class DeleteSelectedCasesC {
public List<WrapperClass> wrp {get;set;}
public Boolean check_box {get;set;}
public List<Case> del {get;set;}
public DeleteSelectedCasesC(){
wrp = new List<WrapperClass>();
for(Case c : [SELECT Id, CaseNumber, Subject, Status FROM Case LIMIT 10]){
wrp.add(new WrapperClass (c, false));
}
}
public PageReference delete_now(){
del=new list<Case>();
for(WrapperClass wc: wrp){
if(wc.check_box){
del.add(wc.cs);
}
}
delete del;
PageReference pr = new PageReference(System.currentPageReference().getURL());
pr.setRedirect(true);
return pr;
}
public class WrapperClass {
public Case cs {get; set;}
public Boolean check_box {get; set;}
public WrapperClass(Case cs, Boolean check_box){
this.cs = cs;
this.check_box = check_box;
}
}
}
I hope it helps you.
Kindly 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. It will help to keep this community clean.
Greetings to you!
One way to delete using Developer Console is to first execute your query
SELECT Id, Subject, Status from Case
Then highlight all the result rows and click on the Delete Row button at the bottom.
Another way to delete multiple cases is through Mass Delete Records.
Go to Setup -> Quick Find -> Mass Delete Records -> Mass Delete Cases -> Search
You can also create a Visualforce page. Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
I hope it helps you.
Kindly 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. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Thank you for your quick response. Can we achieve this using triggers?