I am running sequence of chains jobs. Each job runs a flow who update a record. The next jobs uses the previous job db change. From some reason the next job does not see this update. why?

here is the code: code uses the db to get the prev counter, add it by 1 and save. The idea behind this code is to pass data to a flow to process and get the result in next job in the chain and etc

public class chainJobClass implements Queueable {

public void execute(QueueableContext context) {

    //get the jobCounter from the db. lets say from Account.
    Account acc = [select JobCounter__c from Account where Name = 'AnyCustomer' limit 1];
    //add counter by 1
    double CounterPlusPlus = acc.JobCounter__c++;
    system.debug('JobCounter:' + CounterPlusPlus);
    map<string,double> params = new map<string,double> {'JobCounter' => CounterPlusPlus};
    //call a flow and pass the counter value for the flow to save it to the db
    Flow.Interview pFlow = Flow.Interview.createInterview('FlowJobData', params);
    //flow does the same as the update below. if instead of updating from the flow I update from here it works!!!
    //update acc;    
    // each job submit the next job. iterate 4 times. limit the number of chains job to comply with dev org limit
    if ( CounterPlusPlus < 4 ) {
        System.enqueueJob(new chainJobClass());


  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Nov 18, 2021 at 0:14
  • 2
    Please clarify what a "chain job" is by editing your question.
    – David Reed
    Nov 18, 2021 at 1:40


You must log in to answer this question.

Browse other questions tagged .