I have a scheduled job named "Scheduled_Mail" and its class is "Scheduled_Mail_Controller". From February 13, suddenly the following error occurs.
'Scheduled_Mail' : Dependent class is invalid and needs recompilation: Class Schedule_Notice_Batch_Controller : DML operation Delete not allowed on List<Notification__c>
Scheduled_Mail_Controller
global without sharing class Scheduled_Mail_Controller implements Schedulable {
global void execute(SchedulableContext ctx) {
Schedule_Notice_Batch_Controller noticeBatch = new Schedule_Notice_Batch_Controller();
Database.executeBatch(noticeBatch, 200);
Schedule_Notice_Batch_Controller
public without sharing class Schedule_Notice_Batch_Controller implements Database.Batchable<sObject>{
public Database.QueryLocator start(Database.BatchableContext bc) {
String query = 'SELECT Id,CreatedDate FROM Notification__c ORDER BY CreatedDate DESC';
return Database.getQueryLocator(query);
}
public void execute(Database.BatchableContext bc, List<sObject> targetRecords) {
List<Notification__c> deleteNoticeList = new List<Notification__c>();
for(sObject s: targetRecords){
if((Datetime)s.get('CreatedDate')<=System.today().addDays(-90)){
deleteNoticeList.add((Notification__c)s);
}
}
if(deleteNoticeList.size()>0){
if (Notification__c.sObjectType.getDescribe().isDeletable()){
delete deleteNoticeList;
}
}
}
public void finish(Database.BatchableContext bc) {
}
}
If you know how to solve this problem, please kindly tell me. Thank you.