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
kundlik Yewalekundlik Yewale 

Test class failing with below error:System.AsyncException: The Apex job named "Set Work Order auto assign job" is already scheduled for execution.

Test class failing with below error:System.AsyncException: The Apex job named "Set Work Order auto assign job" is already scheduled for execution.

global void finish(Database.BatchableContext BC) 
    {
        min = Integer.valueOf(System.label.Work_Order_Auto_assignment);
        batchSize=Integer.valueOf(System.label.Batch_size_for_auto_assignment);
        System.scheduleBatch(this, 'Set Work Order auto assign job', min, batchSize);
    }
Best Answer chosen by kundlik Yewale
Raj VakatiRaj Vakati
Update your code as below 
 
global void finish(Database.BatchableContext BC) 
    {
        min = Integer.valueOf(System.label.Work_Order_Auto_assignment);
        batchSize=Integer.valueOf(System.label.Batch_size_for_auto_assignment);
        System.scheduleBatch(this, 'Set Work Order auto assign job'+system.now(), min, batchSize);
    }

 

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

See the schedule jobs which already exists with the schedule job name and delete them wether they are not schedule in future .
If they have scheduled for future runs then change ur new schedule job name.
we cant have mutilple schedule jobs with same name wether they have future runs or not.

Changing the Job Name  lets you schedule the job.

Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.

Best Regards,
​Sandhya
 
Raj VakatiRaj Vakati
Update your code as below 
 
global void finish(Database.BatchableContext BC) 
    {
        min = Integer.valueOf(System.label.Work_Order_Auto_assignment);
        batchSize=Integer.valueOf(System.label.Batch_size_for_auto_assignment);
        System.scheduleBatch(this, 'Set Work Order auto assign job'+system.now(), min, batchSize);
    }

 
This was selected as the best answer