Delete WorklistItem

  • 7 September 2010
  • 4 replies
  • 8 views

Badge +4

Hi all,


How to delete the worklistItem using k2 API's thru code?


Thanks & Regards,


Nithya


 


4 replies

Badge +9

Hi, i havent worked on this, but i have worked on completing a task item through K2API. similarly we can release a worklost item but not deleting the item. Please refer the below code for ur reference......


//Create a K2 connection string to Workflow server using standard defaults
        SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionBuilder = new   SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
        connectionBuilder.Authenticate = true;
        connectionBuilder.Host = ConfigurationSettings.AppSettings["K2HostServer"].ToString(); //"localhost";
        connectionBuilder.IsPrimaryLogin = true;
        connectionBuilder.SecurityLabelName = ConfigurationManager.AppSettings["K2"];
        connectionBuilder.Port = uint.Parse(ConfigurationManager.AppSettings["5252"]);
        connectionBuilder.Integrated = true;


        try
        {
            //open the connection
            using (SourceCode.Workflow.Client.Connection connectionToWorkflow = new SourceCode.Workflow.Client.Connection())
            {
                connectionToWorkflow.Open(ConfigurationSettings.AppSettings["K2HostServer"].ToString(), connectionBuilder.ToString());                SourceCode.Workflow.Client.WorklistItem workListItem = connectionToWorkflow.OpenWorklistItem(SerialNumber);
                workListItem.Release(); // to release the WL Item


                //workListItem.Actions["Task Completed"].Execute(); // to execute the WL Item
            }
        }
        catch (Exception ex)
        {
            string message = ex.Message;
        }


Hope this gives u some idea...

Badge +6

Hi Nithya,


Could you perhaps tell us why you want to delete a work list item - what is the business requirement for this? 


You cannot delete a work list item directly, because that would interfere with the working of the process, or your process would not be able to continue. So some other options available to you are to delete the process instance (you can do this on the SourceCode.Workflow.Management API) or stop the process instance, or alternatively, you could execute an action on the worklist item that would follow a line rule which indicates how the process should respond when it is "deleted". 


Releasing the work list item will probably not help in your case - that only makes a work list item that was opened by a user available to all other users to which it was assigned. 


Hope that helps, and let us know if you have some further details about your particular business case.

Badge +4

Hi,


Thanks for your reply.


My requirement goes like this:  we have 3 different activity ( activity1, activity2, activity3) and Approve or Reject are actions for each activity. if all the users in activity1 are taken approved action then only it will move to activity2. here we are checking the condition if ALL slots outcome=approved" then proceed further.


Users to whom the task should be created is selected from UI screen(aspx page) by admin user. system should allow admin user to change( add destinationuser, delete destination user) the destination user even after assigning the task. In this scenario, when admin tries to delete the user from UI screen , need to delete the particular user worklistItem.  for deleting, cannt use execute action on the worklistItem bcoz we are checking the condition "if all slots outcome= Approved" then proceed to nextActivity.   if we execute delete action then this condition will fail and the task will not proceed to next activity.


Could you please let me know the best way to implement?


Thanks,


Nithya


 


 


 


 

Badge +13

You should use redirect API for User A to User B when Admin changes the user.

Reply