Build a resumable batch Flow
A batch job that stops halfway, for example because of a timeout or an error in an external system, should continue where it stopped when you run it again, without repeating work. This example sends a reminder email to a list of customers from a Flow action.
On the object class you process, add a marker property, for example
Reminder sent(Datetime), and aReminder error(String) property.In the Flow action, use Read Objects with the filter
Reminder senthas no value andReminder errorhas no value, and set Limit result, for example 500.Add a Foreach over the objects read.
Inside the Foreach, send the email. Then use Update Object to set
Reminder sentto now, and Persist Objects for that object in the same iteration.Add a Catch Exception as the last node inside the Foreach, below the steps it should guard, and select Catch all (or the exception types you expect). When a step in the iteration fails, the steps after it are skipped and the Catch Exception runs. Inside it, map the
messagekey of the error to an action variable with Result mapping, setReminder erroron the object to that value, and persist it. The Foreach then continues with the next customer, so one failing customer doesn't stop the run.Run the Flow again, or on a schedule, until the read returns no objects.
Because each customer is marked as soon as the email is sent, a run that stops halfway can be started again safely: it picks up only the customers that haven't been handled. Customers with Reminder error set are left out of later runs. Check them, then clear Reminder error to retry them.
Was this helpful?