Customize Case Number using Sequence

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditShare on Tumblr

By default, each new case created in Bizagi get’s an internal Case Number. In some circumstances you would like to customize this defalut value. For example let’s imagine that we have 2 processes (Expense Claim and Payment) and for each of them we want to generate a specific Case Number.
We are going to use the following RULE:
Process Acronym (e.g EXP for Expense Claim and PAY for Payment) + sequence number (6 digits)
The desired output will be: EXP000001,EXP000002,EXP000003… or PAY000001,PAY000002,PAY000003…

Customize Case Number using Sequence

1. Create 2 new Sequences, one for each process
Go to Modules > Configuration > Sequences
Modules Configuration Sequences and Add 2 new records as in the image bellow
Sequences in BizagiDon’t edit the Id. This is automatically created once you click OK button.
Enter the name of the sequence(string). Important: it must not contain spaces or special characters.
Define the Seed number(integer) which is the initial value of the sequence.
Define the Increment number(integer).
Click OK to save the new created sequences.

2. Get the process id number
Connect to MsSQL and Execute the following query:

SELECT
	A2.[idWorkflow], A1.[wfClsDisplayName] 
FROM 
	[dbo].[WFCLASS] A1
INNER JOIN
	[dbo].[WORKFLOW] A2
ON
	A1.[idWfClass] = A2.[idWFClass]
	AND A2.[wfActive] = 1

The idWorkflow will be used to identify each process. In this example Expenses Claim’s id is 1 and Payment’s id is 2.

3. Configure the Case Numbering
Go to Modules > Configuration > Case Numbering
Customize Case Number using SequenceConfiguration Level: select Application
Application: select App
Use Configuration: select By Rule
Assign the case number at: select Case Creation
Creation Number Rule: click on plus button to create a new expression
case numbering

Create a new Expression
expression manager

var idProcess = Me.Case.ProcessDefinition.Id;
var sSequence = "";
switch(idProcess)
{
	case 1://Expense Claim
	{
		sSequence = "EXP" + CHelper.GetNextSeqValueStr("ExpenseClaim").ToString().PadLeft(6,'0');
		break;
	}
	case 2://Payment
	{
		sSequence = "PAY" + CHelper.GetNextSeqValueStr("Payment").ToString().PadLeft(6,'0');
		break;
	}
	default:
	{
		sSequence = "000000";
		break;
	}
}
sSequence;

final Case numbering
Click OK to save the changes.

4. Restart IIS and clear the temporary files
Go to Windows+R, type inertmgr and click OK.
inetmgr…or search for IIS Manager
iisSelect the Connection from the left panel and from the right panel(Application Pool Tasks) click on Stop.
iis stopOn run type services.msc and click OK.
servicesStop the following services: Bizagi Standard Server Operations Service and BizAgi[name of you project]SchedulerService.
stop services
Go to the location where your project was saved and delete the content of the folder Temporary. This is the default path C:\Bizagi\Projects\[name of your project]\
Also delete the content of this folder C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\[name of your project]\
Start the previous services.
Start the Application pool.
DONE!!!

This is how your INBOX will look like:
processes