How do I delete Apex job submitted by a particular user? Below is what I found online but this script will delete all apex job with status = queued.
Thanks in advance.
//ApexClass apxClass = [SELECT Id FROM ApexClass WHERE Name = 'myScriptName'];
//List<AsyncApexJob> lstJobs = [SELECT Id FROM AsyncApexJob WHERE Status = 'Queued' AND ApexClassId = :apxClass.Id];
List<AsyncApexJob> lstJobs = [SELECT Id FROM AsyncApexJob WHERE Status = 'Queued'];
for(AsyncApexJob job : lstJobs) {
try {
System.abortJob(job.Id);
} catch(Exception ex ) {
System.debug(ex);
}
}