Skip to main content
I'm working with the K2ROM api in a Windows form application to start a new process instance using the following code:

oK2Connection.Open(K2Server);
oNewProcessInstance = oK2Connection.CreateProcessInstance(strProcess);
oNewProcessInstance.DataFields["Purpose"].Value = txtPurpose.Text;
oNewProcessInstance.Folio = cboTaskType.Text;
oK2Connection.StartProcessInstance(oNewProcessInstance, false);
oK2Connection.Close();

A have a second 'Approval' form which tries to find the worklist items for the currrent user and allows the user to approve the task. The OpenWorklist method, however, returns no worklist items. The code is as follows:

oK2Connection.Open(K2Server);
oWorkList = oK2Connection.OpenWorklist("ASP");

foreach (SourceCode.K2ROM.WorklistItem oWorkListItem in oWorkList)
{
cboWaitingForApproval.Items.Add(oWorkListItem);
}

The K2.Net 2003 Workspace Report shows that the process instance was created, active and has the correct destination user. Note that nothing displays under the Workspace Worklist tab.

I'm new at this. Does anyone know what I may be doing wrong?

Thanks
Hi,
I can't see anything wrong with the 'Approval' code.
When you log into workspace and look at the worklist for the user, are there any items in his worklist?
Also have a look at K2server Console to see which user is being authenticated when you start the process and open the worklist via your form and through workspace, and see if that authenticated users are what is expected.

Regards
Gert
Because I'm using a Windows form to do the approval, not an ASP page, I had 'Client Side Code' selected for my event. This option, however, doesn't create the code needed to add the worklist item. Adding the following code to the event seems to have solved the problem:

public void Main(ClientEventContext K2)
{
try
{
K2.AddWorklist("ASP","");
}
catch (System.Exception ex)
{
throw new System.Exception(ex.Message);
}
}

Reply