0

Is it possible to create a collection via a visualforce flow and then update batches of a certain size until complete?

Example:

  1. Flow is kicked off when an account is updated.
  2. Create a collection of all contacts within the account.
  3. Loop through collection in batches of 50 until complete with a wait time inbetween
  4. Each batch has updates performed to it

I'm trying to deal with CPU limits on mass updates to records and so far a PBR and trigger (with @future and without) are both still erroring when there's more than a few hundred records.

  • Unfortunately Flow uses the same engine as Process Builder so it will have the same limits. The only way I could see that might be feasible is an invocable class called by the flow, but that would be better off as a trigger calling a class for performance. – Dave Humm May 12 '17 at 6:37
0

Another option that requires flow, process builder, and data loader. This is best for big one time updates, not a routine process.

Make a flow that works on an individual contact. Make a checkbox field on contact called "Run Flow". Make a process builder that launches the flow if "Run Flow" = true (make sure the process or the flow sets "Run Flow" to false). Using data loader you can upload in batches in the settings. Then you can import a list as large as you want and they will be updated in batches.

0

One solution that isn't really advised. If your flow has screen elements, then most of the flow limits will reset when it reaches that screen. What this means is you can loop through a collection and use an assignment element to just count the number of records that have been looped through. Then have a decision element at the end of the loop that looks for count=50. Only then have it redirect to a screen where you just have to click next. And make sure to reset the counter back to 0.

If you have 1000 records in your collection and you can do 50 or 100 at a time that is great. If your flow is too complex and you can only do 2 at a time, then that's less great. You can run it from a button or directly from the flow screen. But you can't have process builder run a flow with screens.

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.