Create sequence ID
Syntax
generateSequenceId(sequence: $sequenceIdentifier, context:$additionalContext)
Description
Generates the next consecutive number from a sequence. The sequence is uniquely identified by the combination of:
- Sequence identifier (mandatory field): Defines the base sequence (e.g. "invoice" for invoice numbers)
- Optional context: Enables the creation of separate counting sequences. Each unique context combination leads to a separate, independent sequence.
A separate sequence is automatically created for each new combination of sequence identifier and context, starting at 1. Existing sequences are incremented by 1 each time they are called.
The sequences are also retained across sessions. The consecutive numbers are managed centrally in the database.
Parameters
| Name | Type | Type Description | Mandatory | Standard |
|---|---|---|---|---|
| sequence | String | The sequence identifier that forms the basis for the sequence. | yes | |
| context | Any | An optional context parameter that creates separate sequences. Can be: String/primitive values - Specialized objects (uses their ID) - Collections (all elements are combined) | no |
Return value
Type: Double
Returns the next number in the sequence. The first time a new sequence is used, 1 is returned.
Examples
generateSequenceId("invoice", null)
Output: A sequence number for all invoices, starts at 1 and increments by 1 with each call (1, 2, 3, 4, ...)
generateSequenceId("invoice", $productA)
Output: A sequence number for invoices of product A, starts at 1 and increments by 1 with each call (1, 2, 3, 4, ...)