+ Start a Discussion
Mark Seifert 5Mark Seifert 5 

Getting error message when scheduling APEX. An error has occurred in the following section: Exception InvalidScheduledApexClass_desc. Salesforce.com has been notified of the error.

Get the following error in production, but full sandbox I was able to schedule without issue.
RovRov
Can you post your code. ? Without looking at your code it will be difficult to figure out the cause of the error. 
Mark Seifert 5Mark Seifert 5
public class OpportunityStageCalculatorBatch extends StandardBatchFinish implements Database.Batchable<SObject>, Database.Stateful, Schedulable
{
    Set<Id> opportunityIds;

    public OpportunityStageCalculatorBatch( Set<Id> opportunityIds ){
        this.opportunityIds = opportunityIds;
        this.subject = 'Error with SSA Stage Automation';
        this.title = 'OpportunityStageCalculatorBatch';
    }

    public OpportunityStageCalculatorBatch() {
        this.subject = 'Error with SSA Stage Automation';
        this.title = 'OpportunityStageCalculatorBatch';
        // You cannot run the following query using System.today().addDays(-1) or you will get an InvalidScheduledApexClass exception
        List<Course__c> modifiedCourses = [SELECT Id, Opportunity__c FROM Course__c WHERE LastModifiedDate >= LAST_N_DAYS:1];
        Set<Id> oppIds = Pluck.ids( 'Opportunity__c', modifiedCourses );
        this.opportunityIds = oppIds;
    }

    public Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator( 'SELECT Id FROM Opportunity WHERE Id IN :opportunityIds' );
    }

    public void execute(Database.BatchableContext bc, List<SObject> scope){
        Set<Id> oppIds = Pluck.ids(scope);
        SSAOpportunityStageCalculator.ISSAOpportunityStageCalculator calculator = SSAOpportunityStageCalculator.construct();
        try{
            calculator.updateOpportunityStage( oppIds );
        }
        catch( Exception ex ){
            String ids = String.join( new List<Id>(oppIds), ' \n ' );
            String errorMsg = 'Failed to set SSA Stage on Opportunities with the following IDs:\n {0}\n due to the following error: \n'
                    + 'Message: {1} \nStacktrace: {2}';
            errorMsg = String.format( errorMsg, new List<String>{
                ids,
                ex.getMessage(),
                ex.getStackTraceString()
            });
            this.errors.add(errorMsg);
        }
    }

    //TODO: Update batch size once DLRS errors have been fixed
    public void execute(SchedulableContext sc) {
        Database.executeBatch(new OpportunityStageCalculatorBatch(), 5);
    }
}