Skip to main content

Business Sequence Generation

Target audience: Developers & Modelers & Administrators

Available from: 3.11

Overview

This how-to introduces you to the Business Sequence generation capabilities of Flowable Work and how that is integrated with Flowable Design and Flowable Control. The how-to is constructed of multiple parts that are targeting different types of users.

For Administrators and how to monitor current sequences in the system you can read this part.

For Modelers and how to create sequence definitions and use them in BPMN / CMMN this part.

For Developers and how you can use the Java API you can read this part.

Why?

Really often there are requirements to use business sequences for names of Tasks, Instances etc. Flowable provides an easy way to create your own Sequence Definitions and use them in your models. They provide the possibility to create number sequences that are formatted in a certain way. e.g. prefixed / suffixed with a certain value and the number can be padded with 0 to provide a min length for the digits.

info

When using this functionality the generated sequence will be persisted cross transactions. This means that if there is an exception the value that was used is lost and can no longer be created.

Sequence Value Monitoring

Target audience: Developers & Administrators

Flowable Control provides a way to monitor the values of the currently used sequences. This is available under the Utilities section of Flowable Control.

Control Sequence Values

In here the sequence values can be searched on using different parameters. You can then drill down in each value to see its value.

Control Sequence Value Details

When the user has admin rights in Flowable Control then they are also able to update the current value and / or delete it.

Modeling and Using Sequence Definitions

Target audience: Developers & Modelers

Modeling Sequence Definitions

A Sequence Definition is a new Model type in Design. This is used to model sequences in Design. A Sequence Definition is deployed as part of an app as any regular model.

Design Case Sequence

A sequence definition has the following properties:

  • Minimum digits - The minimum number of digits that should be used for the sequence, i.e. if the sequence generated a number with fewer digits, it will use. 0 to left pad the number. e.g. If this number is 5 and the generated sequence number is 1 then the sequence will return 00001.
  • Prefix - The prefix that should be applied to the generated number.
  • Suffix - The suffix that should be applied to the generated number.
  • Start - The first sequence number that should be generated.
  • Increment - The increment step of the sequence. It must be positive or negative, but not 0. If the value is negative then the sequence is descending, otherwise it is ascending.
  • Max Value - The maximum value that the sequence can reach. It must be larger than the start and min values.
  • Min Value - The minimum value that the sequence can reach. It must be less than the start and max values.
  • Allow cycle - Whether the sequence is allowed to cycle, i.e. continue generating values when the minimum or maximum is reached. After an ascending sequence reaches its maximum value, it generates its minimum value. After a descending sequence reaches its minimum, it generates its maximum value. If cycle is not allowed and the sequence can no longer be incremented, an exception will be thrown.

Case Sequence

Design Case Sequence

Here we can see that we are using the Sequence With Prefix and store its value in the variable named caseSequenceVariable. This variable is then used in the Case Instance Name. The variable can also be used in the Case Instance Business Key expression.

Process Sequence

Design Process Sequence

Here we can see that we are using the Sequence With Prefix and store its value in the variable named sequenceVar. This variable is then used in the Case Instance Name. The variable can also be used in the Process Instance Business Key expression.

Ad-hoc Sequence value generation

In addition to the creation of an initial sequence value when a Process / Case starts, the Case and Process Palette have the "Generate Sequence Task" that can be used to model and generate sequence values on demand.

The Generate Sequence Task is located in the Flowable Work section of the palette. It is available in the BPMN and CMMN editors.

Design Generate Sequence Task

The Task has the following options:

Design Generate Sequence Task Details

  • Sequence Definition - Mandatory reference to a Sequence Definition
  • Sequence Value Variable Name - The mandatory name of the variable in which the sequence value will be persisted
  • Store Sequence Value Variable transiently - Flag indicating that the sequence value should be stored as a transient variable.
  • Generate Sequence Number - Flag indicating that a number value needs to be generated. By default, a String value with the formatting arguments defined in the Sequence Definition will be created

Sequence value generation in expressions

In addition to the available task. Flowable provides an easy way to generate a sequence value using an expression. This can be done in one of the following ways:

  • ${seq:next('mySequence')} - This will generate a sequence using the Sequence Definition with the key "mySequence"
  • ${seq:next(mySequenceKey)} - This will generate a sequence using the Sequence Definition with the key provided by the variable mySequenceKey

Monitoring Sequence Values

The generated Sequence Values can be monitored as explained in the previous section

Java API

Target audience: Developers

The Flowable Sequence capabilities are exposed to Developers through the SequenceService. This service provides the following capabilities:

  • Generate Sequence Values
  • Query Sequence Values
  • Update Sequence Values
  • Delete Sequence Values