You need to sign in to do that
Don't have an account?
Scheduled batch doesn't appear to be executing
Hello,
I have the following apex class scheduled to run daily. It says it executes, but there is nothing in the logs at that time even using the finest settings, and the intended result (bounced leads stop getting emails) doesn't happen. I'm sure it's something obvious but I'm bashing my head against the wall. Not only is there a lead with a bounced email, but I specifically created a Test Test lead with no success. Any help would be greatly appreciated.
SCHEDULED CLASS:
public class ScheduleStopEmailingBouncedLeadsBatch implements Schedulable {
public void execute(SchedulableContext ctx) {
StopEmailingBouncedLeadsBatch SEBL = new StopEmailingBouncedLeadsBatch();
Database.executeBatch(SEBL,200);
}
}
CALLED CLASS:
public class StopEmailingBouncedLeadsBatch implements Database.Batchable<sObject>{
public Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator('select id from lead where (emailbounceddate=yesterday and hasoptedoutofemail=false) or name=\'Test Test\'');
}
public void execute(Database.BatchableContext bc, List<Lead> Leads){
try{
for(Lead L : Leads)
L.HasOptedOutOfEmail=true;
}
Catch(Exception e){
system.debug('Exception occured -->'+E.getMessage()+' at line '+e.getLineNumber());
}
}
public void finish(Database.BatchableContext bc){
}
}
Can you show the screen shot of the scheduled job by Setup--> Quick Search (type job) --> Scheduled Job?
Sadly that code didn't work either. I was thinking it was the escapes too. Also tried update Leads; but nothing is getting modified even though select id from lead where (emailbounceddate=yesterday and hasoptedoutofemail=false) or name='Test Test' returns IDs
I did not understand what you were trying to say in your last comments?
You mentioned you copied this code from previous some code and it was working there. From the code you mentioning is the entire batch code or only the following part?
If that is true then it is high possibility thta this code may be running in before update trigger where you don't need any explicit DML Call. Please clarify what issue you are facing after adding that update Leads statement