Hi All, first thanks for reading this.
I have a problem, i need to be able to change a DataField value of a K2 BlackPearl process, from the outside, for example from a personal webservice.
I will then use the DataField value has a trigger to continue a process activity.
But i keep stepping on a Error, i get a Object reference not found with the K2Con.OpenProcessInstance(ps.ID) method, i know that the ps.ID is ok, i can list the processes but that is about it
Here is the code
Thanks you in Advanced
string hostServer = System.Configuration.ConfigurationManager.AppSettings["K2HostServer"].ToString();
//conenct to the K2 host server to get the process list
WorkflowManagementServer wms = new WorkflowManagementServer(hostServer, 5555);
wms.Open();
//grab list of processes within the server
ProcessInstances processInstances = wms.GetProcessInstances();
// connect to the k2 client interface to be able to change datafields
Connection K2Con = new Connection();
try
{
foreach (SourceCode.Workflow.Management.ProcessInstance ps in processInstances)
{
// connect to the specific process using the
SourceCode.Workflow.Client.ProcessInstance myProcessIntance = K2Con.OpenProcessInstance(ps.ID);
// look for the Process with the SGD number
if (myProcessIntance.DataFields["sNumProcesso"].Value.ToString() == NumProcesso)
{
myProcessIntance.DataFields["myDataFieldName"].Value = "mynewvalue";
myProcessIntance.Update();
returnResult = true;
break; // no point in continuing, since we found the process
}
}
}
finally
{
// close the connection
K2Con.Close();
}
}
catch (Exception ex)
{
System.Console.WriteLine("Error updating process datafield, exception ")
}