function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alan_RuanAlan_Ruan 

schedule apex didn't run?

Dear Experts,

I have a schedule job working fine in Sandbox but not in production. Would you please help to take a look and advise?
 
global class rm_ScheduledDeleteInvalidLead Implements Schedulable {

    global void execute(SchedulableContext sc) {

        massDeleteLead();

    }

    public void massDeleteLead() {
        List <lead> leadtoDelete = [Select Id FROM lead WHERE Firstname = 'Unknown' and Lastname = 't.b.d.' and (email = 'unknown@example.com' or email = '') and CreatedDate < LAST_N_DAYS:30];
        delete leadtoDelete;
    }


}

 
YogeshMoreYogeshMore
Hi Alan,

1. Make sure you have schedule same class on production.
2. To schedule class refer following link.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm

3. Steps to check your schedule class
Setting in Scheduled Jobs
4. Except above, if you are getting any error then please share.
Let us know if it helps you.

Regards,
Yogesh More