Define and use sequences

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules examples >

Define and use sequences

Sequences are counters that are incremented by a defined value for each invocation.  Sequences can be used in more than one process and are global to the project. Sequences are often used to guarantee unique values for Attributes associated to a specified case or Customize Case numbers.

 

Using a Sequence to save consecutive numbers in Attributes

Suppose you have a Students Enrollment Process where the Administrative Department of a University registers and enrolls students. Once the student has been enrolled, a consecutive number is generated to identify him/her within the university. This unique number will appear in the student identification card.

 

This is the Data Model of the Process

 

Sequenceexample1

To create a Sequence follow the next steps:

 

1. Go to the Expert View open the Configuration tab and click Sequences.

 

CaseNumberSequences2

 

2. In the new window, click Add to include a new Sequence

 

CaseNumberSequences3

 

The first field, Id, will be valued automatically by Bizagi.

Give the sequence a descriptive name. The name must not contain special characters such as spaces, accent marks, or symbols.

Specify a value for the Seed that corresponds to the initial value of the sequence. It must be a numeric value.

Set the Increment value which is the amount to increase the Seed by. It must be a numeric value.

 

For our example the initial value is 0 (Seed) and it will be incremented by 1 (Increment) each time a student enrolls.

Click OK to save the changes.

 

Sequenceexample2

 

 

3. On the fourth step of the Bizagi Process Wizard select Activity Actions.

Click on the Task where the Sequence will be assigned to the attribute and create an Expression.

 

Sequenceexample3

 

 

4. Create the expression to set the identification number.

 

We will assign the sequence value to the Internal Identification Number attribute. Use the Get next sequence value function which can be found in the Miscellaneous Function category to retrieve the next sequential value.

 

Sequenceexample4

 

The expression would be as follow:

 

Sequenceexample5

 

//Assign the next sequence value to the attribute

<StudentApplication.InternalIdentificationNumber>=CHelper.GetNextSeqValueStr("InternalIdentificationNumber");

 

Using a Sequence to Customize Case Numbers

By default Bizagi assigns a unique Case Number to each instance of a Process with an internal sequence that avoids duplicity and conflicts. You might want to customize this identifiers for all or some of your Processes in which case Bizagi allows you to define your own Case Numbers setting a customized sequence and using prefixes and suffixes.

 

To learn more about how to customize case numbers using sequences please refer to Customize Case numbers.