Bizagi Tips and Tricks

How to customize the case number

Creating a new case in Bizagi means creating a new instance of a specific process. By default, the number of the case/instance, also known as the CASE NUMBER, is maintained by the application using an internal sequence. Having this in place avoids any duplicity or any kind of errors.

Where can I see the case number?

There are two ways to see the case number. The first one is in the Web Portal, on the Inbox page or when you create a new case on the top-right side of the page.

Bizagi Web Portal > Inbox

…and the second one is in the database.


How to customize the case number?

Bizagi allows you to customize the case number by sequence or by rule. To learn more about both of them, go to Bizagi’s website and read the documentation.

Now, the question is which one is the best to use. To be honest, I’ve always used the customization by rule because with this approach you can achieve any kind of customization. The one by sequence is too simple, and therefore you can’t have a complex logic for your case number sequence.

Case numbering by rule

The first thing you have to do is to come up with the case number format. Bear in mind, the case number has to be unique, and as a best practice, I recommend prefixing it with the process 3 letter identification code. What I’ve used before and worked for me was the process prefix followed by a 7 digit number.

E.g PLT-0000001, PLT-0000002, PLT-0000003 and so on.

Also, you could other formats, where you introduce the date.

E.g PLT-20211009-0001, PLT-20211009-0002, PLT-20211009-0003 and so on.

With that in mind, let’s create a new sequence for your process. On my project, I have a process called Platform Administration (prefix PLT). So, I am going to create the following sequence:

Create a new sequence in Bizagi

The next step is to create the Expression which will generate the desired case number format. Go to Bizagi Studio > Configuration > Case Numbering, select the Configuration level, Application, Assign case number, Use configuration and then select the + button to create the rule.

Set the case numbering in Bizagi

Add the following code

Auth:	Valeriu B
Desc:	09 Oct 2021 - set the case number format for each process
var sRuleName = "SetCaseNumber";
Global.Trace(Me,sRuleName,"START --------------------------------------------------------------",1);

var sYear = DateTime.Today.Year;
var sMonth = DateTime.Today.Month.ToString().PadLeft(2,'0');
var sDay = DateTime.Today.Day.ToString().PadLeft(2,'0');
var sDate = sYear + sMonth + sDay;
Global.Trace(Me,sRuleName,"Date: "+ sDate,1);

var iProcessId = Me.Case.ProcessDefinition.Id;
Global.Trace(Me,sRuleName,"Process Id: "+ iProcessId,1);

var sProcessName = Me.Case.ProcessDefinition.Name;
Global.Trace(Me,sRuleName,"Process Name: "+ sProcessName,1);

var sSequence = "";
if (sProcessName == "PlatformAdministration") {
	sSequence = "PLT-"+ CHelper.GetNextSeqValueStr("PLT_CaseSequence").ToString().PadLeft(7,'0');
} else {
	sSequence = "OTHER-" + sDate;

Global.Trace(Me,sRuleName,"Case Sequence: "+ sSequence,1);
Global.Trace(Me,sRuleName,"END ----------------------------------------------------------------",1);

In the IF condition, I’ve used the process name. The value can be taken from Bizagi Studio > Expert > Processes, right-click on the process version, Properties and Name.

Process name in Bizagi

Use the CHelper.GetNextSeqValueStr method to retrieve the next value for the sequence we created at the beginning.

Use the String.PadLeft method to construct the 7 digit number.

The results

Go to the Web Portal and create a new case. You will notice the new case number format.

Inbox with the new case number format