folio

  • 16 March 2006
  • 5 replies
  • 0 views

Badge +1
I need to create folio (folio1000) and incremented it whenever new instances are created by the users. Can anyone show me the code in vb.net

5 replies

Badge
The folio field is a text property of a process instance and you are allowed to set it to anything you want - normally something that will uniquely identify the process instance.

This can either be done when you start the process from your application or the process get set the folio during one of the first activities in the process.

As I understand you would like to set the Folio field automatically without user intervention, so I suggest setting it as one of the start-up actions of your process.

1. Add an activity just below your Start activity on your process. Link Start to your new activity. Link your activity to the original first activity of your process. Call the activity "Set Folio Field".
2. Add a Default Server event to this activity. Call it "Set Folio Field".
3. Go to the code of the Default Server event, and add the following code:

Sub Main(ByVal K2 as ServerEventContext)
K2.Synchronous = True

' Set the folio field
K2.ProcessInstance.Folio = "your own value goes here"
End Sub


If you would like to increment the Folio field from a previous value, best is to use some sort of database to generate the next Folio field for you. Some clients prefer to even use the ProcessInstanceID as part of their Folio field, since this is an auto incrementing ID that the K2 server assigns to each process instance. Your code will then look like:

Sub Main(Bevel K2 as ServerEventContext)
K2.Synchronous = True

' Set the folio field
K2.ProcessInstance.Folio = _
"folio" & K2.ProcessInstance.ID.ToString().PadLeft(5, '0')
End Sub
Badge +1
When I type the code below for increment changes it gives me the following error message:

Sub Main(Byval K2 as ServerEventContext)
K2.Synchronous = True

'set the folio field
K2.ProcessInstance.Folio = "ECN" & K2.ProcessInstance.ID.ToString().PadLeft(5, '0')
End Sub

error message: Compile error. Get Folio(event) line 5: Expression Expected.
Badge +8
The VB compiler sees everything behind the ' as comments. Change it to be ".
K2.ProcessInstance.Folio = "ECN" & K2.ProcessInstance.ID.ToString().PadLeft(5, "0") 
Badge
I've also encountered the need to set the folio programmatically within the workflow, so I've tried the above examples with no luck.

I've set the folio within the first activity and server event of the workflow, and it remains blank (what I set it to when starting the instance).

Any ideas?
Badge
Please disregard my previous post - it does work.

Reply