Starting a Workflow

Initiating a workflow process is a key step in process applications. If you think of a workflow providing a case management solution, A workflow instance may manage a single case or set of cases. A workflow process could correspond 1 to 1 with a Case’s lifecycle OR just a single request related to a case. Other combinations of these are possible as well.

In K2 all the interactions go through a single API. Out of the box assistance provided through the reusable artifacts (be it Infopath, MOSS or forms generation client) also internally use this API to start process instances.

The namespace used is Sourcecode.Workflow.Client and a corresponding DLL is found in the GAC.

using (SourceCode.Workflow.Client.Connection con = new Connection())
ProcessInstance pi = con.CreateProcessInstance("workflowproject\\workflowprocess"); pi.DataFields["fieldname"].value = "value";

you can also set XMLDatafileds. So, if you have an infopath based process you can start that as well through the sample code above. all you need to do before the startprocessinstance call is to make sure that the relevant XMLDatafield has the xml value set  as the form is submitted by a user 🙂

Interaction with the worklfow process instance typically happens when a task is assigned to a user for action. There are two other means for interacting with a process instance as well.

%d bloggers like this: