-1

I have a Flow on Account which has two paths:

  1. Run Immediately
  2. Run after 1 minute of Account's Last Modified Date

In the first run, it runs regular business logic.

In the second run, there's a decision element which checks for 1 checkbox field and if it's TRUE, then it will call a future apex method and marks the checkbox back to FALSE.

So when I update that checkbox field to TRUE for a bunch of records using dataloader, the expectation is that:

  1. The checkbox field on each Account is marked true - Working as expected
  2. Regular flow logic is executed - Working as expected
  3. The flow interview is scheduled to run after 1 min - Working as expected
  4. The future apex is executed after 1 min - This happens only on the first record of the list of scheduled interviews
  5. The checkbox field on each Account is marked false - Working as expected

I was under the impression that the flow will execute the future apex for each Account record, am I missing something here? Thanks in advance

2
  • 1
    I'll almost bet that your invocable apex is not bulkified - and it is only handling the [0]th element of its input request arg (which is a list, each element corresponding to an interview in the transaction)
    – cropredy
    Commented Mar 14 at 20:43
  • It makes perfect sense. Thank you! Turn this comment to an answer and I'll mark it
    – apz
    Commented Mar 15 at 13:54

1 Answer 1

0

I'll almost bet that your invocable apex is not bulkified - and it is only handling the [0]th element of its input request arg (which is a list, each element corresponding to an interview in the transaction)

For example, if your invocable looks like this

@InvocableMethod (..)
public static void doWork(Id[] ids) {
   doFutureWork(ids[0]);
}

@Future
private static void doFutureWork(Id id) {
  .. do async stuff
}

A transaction, such as Data Loader, will present multiple Flow Interviews. When each interview reaches the invocable apex point, the interview pauses until all the transaction's interviews reach that point.

  • Then, a single call to the invocable Apex is made, passing a list of arguments where argument[0] corresponds to interview[0], argument[1] corresponds to interview[1].
  • So, the reason why only the first data loader update calls the future is because the invocable is not bulkified - it is only handling request[0] (i.e.. interview[0])

How you bulkify this is up to you. Ultimately, since a Data Loader transaction could be 200 interviews, the future method should be bulkified as well

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .