Skip to main content
Hi,

I need help trying to get the Process originator. It seems to return back results for ACTIVE processes only and not completed ones. Any idea what i'm doing wrong here?


public string GetProcessInstanceOriginator(long procInst)
{

try
{
string k2Server = "Teknck2stage";
string k2ProcessName = "ITFARITFAR";
string tmpOriginator = "";

SourceCode.K2Mng.K2Manager K2Man = new SourceCode.K2Mng.K2Manager();
if (K2Man.Login(k2Server, 5252))
{
SourceCode.K2Mng.ProcessInstances ProcessInstances = K2Man.GetProcessInstancesAll(@k2ProcessName, "%", "%", null, null);
foreach (SourceCode.K2Mng.ProcessInstance ProcessInstance in ProcessInstances)
{
if (ProcessInstance.ID == procInst)
{
tmpOriginator = ProcessInstance.Originator;
return tmpOriginator;
}
}
}
return tmpOriginator;
}
catch (Exception ex)
{
throw ex;
}

}
Hi Vinny T,

The code you provided will just bring back active processes.
To return originators for completed processes you need to use the Workspace web service which provides a reporting framework.
All this is explained very nicely in KB article 21 with some sample code.(http://kb.k2workflow.com/Articles/KB000021.aspx)

With this you will be able to retrieve a list of originators.

Regards,

JohanL
Is it a documentation bug then because k2mng.hlp file for GetProcessInstancesAll does mention about completed, stopped, and deleted items.
Case Is = 3
oListItem.SubItems.Add("Complete")
Case Is = 4
oListItem.SubItems.Add("Stopped")
Case Is = 5
oListItem.SubItems.Add("Deleted")
Hi Peter,

It must be a documentation issue as it will definitely not be possible to return any processinstances for a process a completed or deleted state.

When processes complete they are removed from the K2 database. (This is to keep the server performance at its best.) If you require information it can be sourced from the K2Log database.

When deleted process information is deleted from the K2 database. (It is optional to delete it from the log database.)

The K2MNG API communicates via the K2Server to the K2 database only so cannot get to the deleted/completed instances.

Regards,
Conrad

Reply