Skip to main content
I know this is a probably very simple task but I can't find any info regarding this point - what library should I include in my aspx page (VB-code) to have the ability of operating with K2 classes.
SourceCode class is installed but I can't set the K2 field by using K2.ProcessInstance.DataFields("Man3").Value by default.
Can anybody help me?

And second question - how to obtain the value of process instance serial number field - is it K2.ProcessInstance.DataFields("SN").Value or anything else?

Regards,
Andrei
You'll have to reference the K2ROM.dll assembly. Have a look at the help file for sample code doing exactly this - setting process level variables.

The serial number is NOT a property of the process instance. It is rather a property of an Event instance like a Worklist item or a Server event. You'll have to open a specific Worklist item to get to the Serial number of the item. Have a look at the Worklistitem.SerialNumber property.

Both of these questions are covered in the Help file under the K2ROM object model.

Hope this helps,
Ockert
Thanks Oskert!
Hi Webber,

I am not sure what classes you are referring to, my guess would be K2ROM. The K2.net Runtime Object model allows developers to manipulate running process instances.

You basically have two ways of altering data within a running process instance:
1. Using the WorklistItem object, K2.net 2003 will only allow you to open the Worklist Item if you are the destination user or the manager of destination user.
2. Using K2ROM,Connection.OpenProcessInstance, with this method you need to be a K2.net Administrator.

For your second question:
A K2.net Process does not have a serial number, typically WorklistItems and ServerItems generates a serial number

Have a look at the K2ROM help file for more information.

Also visit: http://portal.k2workflow.com/downloads/training.aspx and have a look at the following module:

Module 07 : Developing against the K2.net 2003 Object Model - The student will learn how to programmatically interact with the K2.net server by utilizing the K2.net ROM object. The object model together with its various methods and properties will be discussed. After completing this module the student will know how to programmatically start new workflow processes and how to interact and manipulate existing workflow process instances.
Hi Renier,

Sorry but my skills in .Net programming is too low at this moment.
Just clarify one thing to me please:
I want to setup a value for a field that I created it in K2.Net Studio among other datafields
I guess it is not correct to write something like
SourceCode.K2ROM.DataFields("MyField").Value=AAA

where AAA is defined as a string parameter : DIM AAA As String
Hi Webber,

Nope that code is not correct. You can do something like:

 oK2Connection.Open(strK2Server)

'Get Worklist for current Logged on User
oWorkList = oK2Connection.OpenWorklist("ASP")

For Each oWorkListItem In oWorkList
If oWorkListItem.SerialNumber = strWorkListItemSerial Then
'Update Process Data or XML Field
oWorkListItem.ProcessInstance.DataFields("Result").Value = "Complete"

'Update Activity Data Field
oWorkListItem.ActivityInstanceDestination.DataFields("Result").Value = "Complete"

oWorkListItem.Update()
'OR
oWorkListItem.Finish()

ElseIf oWorkListItem.ProcessInstance.Folio = strFolio Then
oWorkListItem.GotoActivity("Declined", False) 'Force the process to another Activity contained in the same Process
'OR
oWorkListItem.Redirect(strNewDestination) 'Redirect the WOrkitem to a different user
'OR
oWorkListItem.Sleep(True, 24) 'Removes the workitem from the users worklist for the duration specified in seconds
End If
Next

Reply