cancel
Showing results for 
Search instead for 
Did you mean: 

cancel workflow when content deleted

darionis
Champ on-the-rise
Champ on-the-rise
I have a "customFolder" type based on cm:folder and a custom jbpm workflow that operates on customFolder (customFolder is in workflow's package).

If I delete customFolder, I also want to cancel workflow instance. Now, workflow instance remains after customFolder deletion and users see tasks that are related to nonexistent content.

I tried with onDelete policy combined with "cacncelWorkflow" call but it didn't really work and produced various errors including message about ALF-12358.

My question is: what is the best way to cancel workflow when content is deleted?

Thanks!
2 REPLIES 2

vinaxwater
Champ in-the-making
Champ in-the-making
I think, when start worflow must remove action delete, cut, coppy (only exist action view) of content. If workflow cancel when open full action for content. Smiley Very Happy

I did with this. My guest for you.

I tried with BeforeDeleteNodePolicy, like this:


public void beforeDeleteNode(final NodeRef object) {
    List<WorkflowInstance> wfs = workflowService.getWorkflowsForContent(object, true);
    for (final WorkflowInstance workflow : wfs) {
       workflowService.cancelWorkflow(workflow.getId());
    }
}



However, when I delete my node, beforeDeleteNode gets called 10-15 times and then I get:
org.springframework.dao.ConcurrencyFailureException: Child association not found: 1081.  A concurrency violation is likely.
This can also occur if code reacts to 'beforeDelete' callbacks and pre-emptively deletes associations
that are about to be cascade-deleted.  The 'onDelete' phase then fails to delete the association.
See links on issue ALF-12358.

I guess I shoud cancel workflow using OnDeleteNodePolicy but I can not get workflow reference since the node is already gone at that point?

Any suggestions, please?