The schedule_batch_mdm_role_definition I believe is working fine.

    global class schedule_batch_mdm_role_definition implements schedulable 
        global void execute(SchedulableContext sc)
            batch_mdm_role_definition myBatchClass = new batch_mdm_role_definition();
            database.executeBatch(myBatchClass , 100);

In the finish method of the batch_mdm_role_definition I am thinking I need to schedule the next batch job aka batch_mdm_contact to allow for the previous job time to complete due to salesforce asynchronous handling.

This works but my challenge is I need to limit scope to 100 because of the callout limit.

Question: How can I restructure this part to schedule the next job and respect the 100 callout limit.

public void finish(Database.BatchableContext bc)
      string cronID = System.scheduleBatch(new batch_mdm_contact(), 'Chained Sync Handle', 2);

Additional Insight: The batch_mdm_contact class can query for thousands of records.


Because you want to limit the scope, you'll want to call the class in this manner:

string chronId = system.scheduleBatch(batchable, jobName, minutesFromNow, scopeSize);

See ApexDocumentation for Schedulable which explains the subject in more depth.

I don't know that you would need to implement the schedulable interface as @AdrianLarson suggests since you can call this directly and the job would be added to the end of the FlexQueue. I would recommend that you first check for available limits in the Queue before calling this method.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.