Skip to main content
We are currently planning to extend our solution with typical maitenance workflows.

Today we have a registration workflow in place for a specific business entity, and now we need to control the change management process for this entity.

What is the best practice for launching such workflows with K2.NET and InfoPath forms? With webforms we could easily called upon a SmartForm and passed a entity ID as a querystring parameter, but launching the InfoPath based process is simply a reference to the xsn file.

Any best practices for doing this?
I've coded so that the XML document template in the XSN file is merged with each row from a SQL query (my driving data). Each XML document is passed into the K2InfoPathSchema field of the K2ROM.Connection Instance.

Public Function startOneK2Process(ByVal processName As String, ByVal k2InfoPathSchemaValue As String, _
ByVal k2Server As String, ByVal k2ConnectionString As String) As String

Dim retval = ""
Try
Dim c As K2ROM.Connection = New K2ROM.Connection

' Open the connection to K2 Server, and Create the process
c.Open(k2Server, k2ConnectionString)
Dim instance As K2ROM.ProcessInstance = c.CreateProcessInstance(processName)

' Find the K2InfoPathSchema in the Process XmlFields
' collection and set it's value
Dim field As K2ROM.XmlField
For Each field In instance.XmlFields
If (field.Name.Equals("K2InfoPathSchema")) Then
' Yes, set it's value
field.Value = k2InfoPathSchemaValue

' And start the process
c.StartProcessInstance(instance)
If instance.Status = K2ROM.ProcInstStatus.Error Then
retval &= "Error within the K2 Process: " & instance.Description & ";"
ElseIf instance.Status = K2ROM.ProcInstStatus.Stopped Then
retval &= "Stopped within the K2 Process: " & instance.Description & ";"
End If
''retval &= "K2 ProcessDescription: " & instance.Description & ";"
c.Close()

Return retval
End If
Next
c.Close()

' If we get down here, the K2InfoPathSchema wasn't found
' in the Process XmlFields
' This is an error condition
retval &= " K2InfoPathSchema not found in K2ROM.XmlField;"
Catch ex As Exception
retval &= ex.ToString
End Try

Return retval
End Function

Reply