AnsweredAssumed Answered

Delete or Cancel Workflow programmatically in end state

Question asked by sebp on Nov 1, 2010
Latest reply on Nov 29, 2010 by zaizi
I want all tasks from the "My Completed Tasks" dashlet to disappear as soon as a workflow is finished. Normally the user who initiated the workflow has to cancel it then the tasks disappear. I thought I could cancel or delete the workflow programmatically as part of the end-state task of the workflow itself, like this:

<end-state name="end">
<event type="node-enter">
    <action class="de.hmedia.alfresco.workflow.WfCancelHandler"/>
</event>
</end>

But this gives an sql error. I think this error occurs because the workflow is deleted within the same transaction that currently signals the end state of the workflow. Then I used the RetryingTransactionHelper to run the deletion of the workflow in a new transaction but this causes a dead-lock.
Is there any way to automatically delete the workflow (or remove the completed tasks of a workflow) as soon as the workflow is finished?

Outcomes