ReleaseWorklistItem

  • 21 June 2006
  • 2 replies
  • 5 views

Badge +1
Hi,

I used k2mng 's ReleaseWorklistItem function.

oMng.ReleaseWorklistItem(oWli.ID);

In my app an activity is allocated to more than one users and there is single slot.

Say User A opens (locks) this activity, I want to be able to release it for use by all other destination users. I tried this method but nothing seems to be happening. Can you please help.

vingupta@deloitte.com

Worklist oWorkListCollection = oK2Connection.OpenWorklist(criteria);
if( oWorkListCollection != null )
{
if( oWorkListCollection.Count > 0 )
{
foreach(WorklistItem oWli in oWorkListCollection)
{
SourceCode.K2Mng.K2Manager oMng = new SourceCode.K2Mng.K2Manager();
oMng.Login(ApplicationConfig.ConfigData.K2ServerName, 5252,K2ConnectionFactory.GetK2LoginString());
if( approver == null)
{
oMng.ReleaseWorklistItem(oWli.ID);
}
else
{
oMng.RedirectWorklistItem(oWli.ID, approver.Approver_AD);
}
oMng.Logout();
}
}
}

2 replies

Badge +8
I am not sure why it isn't working but what you might try instead of using the K2MNG to release and redirect is to use the release and redirect that is built into the worklist item object.

Ex:

Worklist oWorkListCollection = oK2Connection.OpenWorklist(criteria);
if( oWorkListCollection != null )
{
if( oWorkListCollection.Count > 0 )
{
foreach(WorklistItem oWli in oWorkListCollection)
{
if( approver == null)
{
oWli.release();
}
else
{
oWli.redirect(approver.Approver_AD);
}
}
}
}
Badge +1

This is how I got it to work (only after installing the 0807 release): 


 


SourceCode.Hosting.Client.BaseAPI.

SCConnectionStringBuilder connectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();


connectionString.Authenticate =

true;


connectionString.Host =

"k2server";


connectionString.Integrated =

true;


connectionString.IsPrimaryLogin =

true;


connectionString.Port = 5555;


WorkflowManagementServer

workflowServer = new WorkflowManagementServer();


workflowServer.CreateConnection();


workflowServer.Connection.Open(connectionString.ToString());


foreach (WorklistItem worklistItem in workflowServer.GetWorklistItems("", "", "", "", "", "", ""))


{


if (worklistItem.Status.ToString() == "Open" || worklistItem.Status.ToString() == "Allocated")


{


workflowServer.ReleaseWorklistItem((int)worklistItem.ID); // Note the typecast to (int) creates potential for overflow error but you have to do it to get it to work.


}


}


workflowServer.Connection.Close();

Reply