You need to sign in to do that
Don't have an account?
Clement Debrueres-Bartoli
How to delete Cases owned by specific queue 4 hours after Case Closure?
Hello fellas,
For my spam emails, I currently have this process for Cases:
-if Custom field "Mark as Spam" is ticked by User, then move the Case to "Spam" queue and mark the Status as "Closed"
This PB works well, no problem. All my Spams go to this queue, in Closed status.
However I would also like to integrate the deletion of those Cases in the process: Case should be deleted 4 hours after they have been moved and closed. (I dont want to delete immediately, I need the Case to stay a few hours in the queue)
There are several options, but which one would be the simplest and cleanest to achieve this regular deletion of spam cases?
Thank you very much
For my spam emails, I currently have this process for Cases:
-if Custom field "Mark as Spam" is ticked by User, then move the Case to "Spam" queue and mark the Status as "Closed"
This PB works well, no problem. All my Spams go to this queue, in Closed status.
However I would also like to integrate the deletion of those Cases in the process: Case should be deleted 4 hours after they have been moved and closed. (I dont want to delete immediately, I need the Case to stay a few hours in the queue)
There are several options, but which one would be the simplest and cleanest to achieve this regular deletion of spam cases?
Thank you very much
All Answers
______________________________________________
global class DeleteSpamCases implements Database.Batchable<sObject>,System.Schedulable{
global final String Query;
global Database.QueryLocator start(Database.BatchableContext BC){
Date dToday = Date.today();
Date t = Date.newInstance(dToday.Year() , dToday.Month() , dToday.Day() );
return Database.getQueryLocator([Select id from Case where Owner.name = 'SpamBox']);
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
List<Case> lCase = new List<Case>();
for(sobject s : scope){
lCase.add((Case) s);
}
delete lCase;
}
global void finish(Database.BatchableContext BC){
}
public void execute(SchedulableContext SC){
Database.executeBatch(new DeleteSpamCases(), 20);
}
}