Mark the process status as Deleted in server event?

  • 6 September 2013
  • 1 reply
  • 3 views

Badge +13

The Process status shows Deleted (5) if you use K2 Workspace and delete workitem and keep log, otherwise it uses the standard Completed (3) status.


I would like the status to indicate Deleted if the workitem was cancelled by the user (I have a Terminate activity in the process). 


re:  4.6 ServerLog Database ERD.pdf


1 reply

Badge +8

There's nothing out of the box that will allow one to set the status to anything other than the expected value (3). Here's one option I can think of from the top of my head:


You could create an external service (a timer job or windows service) that checks a table in SQL (or any storage mechanism of your choice). This table gets populated by the last event in the Terminate activity. This event should also be async in order for the process to stay active. So when a new row is added to the table (which should include the process instance id), you could then use the Management API and call the DeleteProcessInstance method, passing in the option to not delete the log entries. This way there is no direct database manipulation.


The only tricky portion here would be to check if the process is in the correct state before calling the delete method. It should be OK most of the time, especially if you're using a polling mechanism, but I would still just do a simple check before the delete, sleep the thread for a second or two if needed and then loop again. Give it a finite number of loops too, just in case.

Reply