-1

I am using Queueuable Interface in trigger like this,

System.enqueueJob(new testobjectmethod(trigger.new,trigger.oldMap))

My Queueuable class:

public class testobjectmethod implements Queueable,Database.AllowsCallouts {
       test__c[] newList;
       Map<id,test__c> oldMap;
public testobjectmethod(test__c[] newRecords,Map<id,test__c> oldRecords){
       newList = newRecords;
       oldMap  = oldRecords;
}
public void execute(QueueableContext context) {
        Handlerclass.test(newList,oldMap);
    }

}

Daily in 24 hours period , it is running more times, whenever the record operation performes asynchronously.while scheduling new job interface, i am facing the error - we ran into an error “You have exceeded the maximum number (100) of Apex scheduled jobs”

How to overcome this error?

2

1 Answer 1

2

This error cannot be caused by queueable classes, as they are not subject to a 100 limit. Somewhere in your code you have either System.schedule or System.scheduleBatch that is causing this error; you'll need to address this issue in that code. Note that Batches should generally not be called from a trigger for this reason.

7
  • while removing this queuable from the code, it is working, i am not facing any error
    – user55489
    Apr 27, 2021 at 12:33
  • This queuable is daily running with so many times like this batches processed 0 and batches failed 0 in apex jobs
    – user55489
    Apr 27, 2021 at 12:34
  • @VinothBalasubramaniyan That's only because you have a trigger that's loading too many Schedulable or scheduleBatch calls. You will need to address the problem at its source.
    – sfdcfox
    Apr 27, 2021 at 12:38
  • ok thank you, if we change it you future method is it work?
    – user55489
    Apr 27, 2021 at 12:41
  • @VinothBalasubramaniyan Maybe. You're limited to one asynchronous call while using Queueable, so some restructuring may be necessary.
    – sfdcfox
    Apr 27, 2021 at 12:42