Answered

How to set the running number in Business Rule setting

I have 'Order no' attribute in entity.

I want to run that Order no. starting from '2010040400001', where the first part is the yyyy-mm-dd of that given day.

The second part is the actual running no. which increases by one...

Please suggest me how to do it...

Thank you very much

Best Answer
photo

Dear Charoenchai,

You may create and use Bizagi Sequences for any purpose in your process.

The sequence definition you need will have seed=100000 and increment=1, and it use and next value can be set directly in the case numbering definition in Bizagi (supported in Bizagi Enterprise edition).

For this specific case in which you want this sequence to apply for your running number of orders (case identifiers), you need to create a Bizagi expression to customize this running order.

This is done by obtaining the current date with Me.getXpath("DateTime.Now") and using CHelper.GetNextSeqValueStr("YourSequence") to concatenate the last part of your order.

Further examples at: http://wiki.Bizagi.com/en/index.php?title=Example2_Sequences.

Best regards,

photo
0

Dear Charoenchai,

You may create and use Bizagi Sequences for any purpose in your process.

The sequence definition you need will have seed=100000 and increment=1, and it use and next value can be set directly in the case numbering definition in Bizagi (supported in Bizagi Enterprise edition).

For this specific case in which you want this sequence to apply for your running number of orders (case identifiers), you need to create a Bizagi expression to customize this running order.

This is done by obtaining the current date with Me.getXpath("DateTime.Now") and using CHelper.GetNextSeqValueStr("YourSequence") to concatenate the last part of your order.

Further examples at: http://wiki.Bizagi.com/en/index.php?title=Example2_Sequences.

Best regards,

photo
0

But the problem is how to set a period within which a counter runs, taking in mind that counters of each period must run separately from each other.

For example, now in 2011 a counter runs for this year but when I decide to add a document into the 2010 period a counter for 2010 must run from the sequence of the 2010 period.

I mean how to set a time period for a sequence within which it runs?

photo
0

I would say create a new entity to record year data from 2010,2011...to 2200.

Then, first read the year of the DateTime.Now. If that year already existed in the entity, add 1 to the counter information.

Else (if the year not existed), create the row and set the counter to start at 1.

photo
0

This feature is useful for our ORDER and INVOICE FORMS numbering.

photo
0

Dear Users,

Take into account that you can customize your Case Identifier by using a custom Bizagi rule to generate this unique identifier with date information.

Within this rule expression, you may include both a sequence value and operations handling dates, such as those DateTime.Now to obtain the current year.

Best regards,

photo
0

To include both, where do I need to go?

Do you have any sample online?

photo
0

Dear Bachie.sy,

To set an advanced or custom case numbering calculation for your processes, you would define this as shown:

casenumberingbyrule

Notice that in the "creation number rule" you may use an existing rule or create a new one.

When creating a new one, in an expression module you need to return a string.

Within the expression module, use the DateTime object. For example, Me.getXPath("DateTime.Today") to get its .Year, .Month, etc..

Best regards,

photo
0

Thanks a lot.

How about resetting the sequence every year?

And using the default configuration inside the Rule?

//Obtain the current year in a variable

var year=DateTime.Today.Year

//Identify the process according to its ID

if(Me.Case.ProcessDefinition.Id == 138)

{

//Build the text of the case identifier

"IM - "+CHelper.GetNextSeqValueStr("IMNumber")+ " - "+year;

} else

if(Me.Case.ProcessDefinition.Id == 154)

{

"CCM - "+CHelper.GetNextSeqValueStr("CCMNumber")+" - "+year;

} else

if(Me.Case.ProcessDefinition.Id == 178)

{

"OPM - "+CHelper.GetNextSeqValueStr("OPMNumber")+" - "+year;

} else

{

//want to use the default configuration here

}

Any guidance on the right direction is appreciated.

photo
0

I have an idea on how you can reset your sequence. Well, you'll not really reset the sequence, but emulate that.

First, you must have a table with 2 int columns: "base" and "year". Manually create one record in this table with base=0 and year=2012 (the current year). Then, take a look at the code below (I haven't tested it, but it'll give you the idea):

var year = DateTime.Today.Year;

var base = retrieveBase(year); // looks in DB the "base" value of the given "year"

var next = CHelper.GetNextSeqValueStr("MySequence");

if (base == null) { // it's a new year

base = next - 1;

saveBase(year, base); // saves new record in DB with "base" value for the new "year"

}

var caseNumber = next - base; // the trick

var prefix = "BLAH-";

var suffix = "-" + year;

// gives you something like BLAH-1-2012, BLAH-2-2012 and so on...

var formattedCaseNumber = prefix + caseNumber + suffix;

A code like that must be executed to generate your case number. It'll save in database the last generated value of the sequence when year changes. The trick is always subtracting this value from the next sequence value.

I hope it helps.