Skip to main content

Hi,


I wanted to delete the work item at the end of my process (Workflow). Is it possible to delete the work item through work flow design itself (Already I worked in FileNet BPM, there we have a terminate step (component) it will delete the work item automatically). Similar to that any component is there to delete the work item through work flow itself? Or I have to do the API search and delete the Process Instance. Please guide me.


Thanks in Advance.


Regards,


 -Balaji. S

To provide the best answer I think we might need more information on your scenario.  What exactly do you mean by delete?


In a lot of processes I build I'll provide a cancel task available to the originator so that if they choose they can cancel the process and it'll expire (maybe this is what you mean by delete) any open tasks assigned in the process.  You can do this using the code in a server event similar to the following which I typically add to the "Completed" or "Cancelled" final activities in the process.


 




 



 



 


            if (Convert.ToBoolean(K2.ProcessInstance.DataFieldss"GotoAlreadyCalled"].Value) == false)
            {
                K2.ProcessInstance.DataFields "GotoAlreadyCalled"].Value = true;
                K2.GotoActivity(K2.ActivityInstanceDestination.Activity.Name);


            }




Using this method it still leaves a process audit trail in the K2 Log Database which is what I would recommend.


If you actually want to delete the active process and the entry from the K2 Log database you would need to write K2 Management API code that would have Admin permissions on the K2 Server to do this.  However, you would need to do this from an external assembly outside of the K2 process otherwise it could affect the K2 server.  Take a look at the following class in the out of the box K2 documentation:                     


SourceCode.Workflow.Management Assembly > SourceCode.Workflow.Management Namespace > WorkflowManagementServer Class : DeleteProcessInstances Method


Reply