Repeating Activities in BPMN

Filip Stachecki
26-09-2023

7 min

Business Process Model and Notation (BPMN) is a widely used notation for modeling business processes. One of the key elements in BPMN is the use of loops. A loop allows a process to repeat a set of activities more than once.

In this article, we'll take a closer look at three ways of creating loops in BPMN: Going back, standard loops and multi-instance loops.

Going back

There is an easy way of repeating activities without using predefined loops. Just use gateway(s) to perform the activity again.

This pattern can be applied to both tasks and activities.

Standard Loops

A standard loop is used to repeat a set of activities as long as a certain boolean condition is met. This type of loop is graphically represented by a small line with an arrowhead that curls back upon itself.

The condition is evaluated for every loop iteration, and may be evaluated at the beginning or at the end of the iteration. By default, the evaluation takes place at the end of the iteration.

Standard loop notation is more compact than going back with a gateway, but all details are hidden in activity attributes. You can show them by attaching a comment to an activity.

In addition, you have the option to specify a numeric cap. The number of iterations may not exceed this cap.

Standard loops are like "while" or "do..while" loops in programming. Within a standard loop, execution of activities is always sequential.

Standard loops are useful when you don't know how many times you will have to repeat an activity.

Multi-Instance Loops

A multi-instance loop is used to repeat a set of activities for multiple instances of a collection. When all instances are completed, the multi-instance activity is completed.

The instances may execute in parallel or may be sequential.

This type of loop is graphically represented by three horizontal (≡) or three vertical (III) lines.

Now comes the hard part - how to remember which representation means parallel and which is sequential?

Let me show you a way to remember it once and for all:

When you create a multi-instance activity, you can optionally specify attributes to configure specific behavior for the activity.

The attribute isSequential determines whether instances are generated sequentially (true) or in parallel (false).

A loopCardinality expression is used to specify the desired number of instances. Another way to specify the number of instances is using the loopDataInputRef attribute. The number of items in the collection determines the number of Activity instances. In order to initialize a valid multi-instance, either the loopCardinality expression or the loopDataInputRef MUST be specified in advance.

In addition, the completionCondition attribute defines a boolean expression that when evaluated to true, cancels the remaining activity instances and produces a token.

I'm a big fan of just using multi-instance activities in conjunction with data collections and not bothering with all sophisticated attributes (16 in total! 😱) of such activities.

The multi-instance activity is similar to the "for each" loop in programming.

Multi-instance loops are useful when you have a collection of data and want to iterate through it.

Summary

Loops are a powerful feature in BPMN that allow processes to repeat a set of activities as long as a certain condition is met or for multiple instances of an object within a single data collection.

Standard loops and multi-instance loops are two types of loops that can be used to simplify notation. Since all configuration is hidden in attributes, they are more suitable for executable BPMN processes than for visual presentation in diagrams.

By understanding these loop types, business analysts and process designers can create more accurate and efficient business process models.

Messy BPMN Quiz (Level 2, Lesson 4)

Take the Repeating Activities in BPMN Quiz to test your knowledge!