Auto generate case number from section field and date

Good day.

I am new to BPM Online(And C#). I just registered a 14 day free account to try it out.

I want to use the sub process to create a case number when a new record is created on a section. Please see the image below:

When the new record is saved the process starts and reads the zone filed from the request record as depicted below:

Upon reading the zone field I then assign the zone filed to the zone process variable using the formular task as depicted below:

I then use the zone process variable to formulate the case number in the code script as depicted below:

string unique_numer =  DateTime.Now.ToString("yyMMddhhmmss");
string  zone_val = Get<Guid>("zone").ToString();
string case_number=(zone_val+"-"+unique_numer)
 
Set("case_number",case_number);
return true;

The challenge I am facing is to get the value of the selected lookup zone field to store the value into zone_val string filed.

How to get the selected value from the zone lookup filed using C# code. The value that I get is a Guid data type and cannot get the value of the lookup.

I need to store the generated CaseNumber to the case_number field in the database as depicted below:

You help will be highly appreciated as I am currently stuck.

 

Like 0

Like

4 comments

Dear Tebogo,

You may create a system setting that will store this number and use it in the future number generation. You can find detailed example here: https://academy.bpmonline.com/documents/technic-sdk/7-13/how-add-auto-n…

Best regards,

Angela

Assuming you want the field name in the Zone Table : 

var uc = Get&lt;UserConnection&gt;("UserConnection");
 
Guid zoneId = Get&lt;Guid&gt;("zone");
 
var esq = new EntitySchemaQuery(uc.EntitySchemaManager.GetInstanceByName("Zone"));
esq.AddColumn("Name");
var entity = esq.GetEntity(uc, zoneId );
string zoneName = entity.GetTypedColumnValue&lt;string&gt;("Name");

 

Angela Reyes,

Thank you very much Angela.

Jerome BERGES,

Thank you very much Jerome, highly appreciate it!

Show all comments