Creating behavior for deleting associated workflow after document deletion

cancel
Showing results for 
Search instead for 
Did you mean: 
imanez1
Active Member II

Creating behavior for deleting associated workflow after document deletion

Hello,

I want to create a behavior that cancels associated workflows after file deletion. After some research, I found out that I need to implement the following Behavior/Policie:

public void beforeDeleteNode(final NodeRef nodeRef) {
   List<WorkflowInstance> activeWorkflow =       serviceRegistry.getWorkflowService().getWorkflowsForContent(nodeRef,true);
      for (WorkflowInstance w : activeWorkflow) {
             wIds.add(w.getId());
       }

}

public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) {
    if (wIds.size() > 0) {
          serviceRegistry.getWorkflowService().cancelWorkflows(wIds);
    }
    wIds.clear();
}

My problem is I don't know where or how to implement this, any help is appreciated.

2 Replies
angelborroy
Alfresco Employee

Re: Creating behavior for deleting associated workflow after document deletion

You can start with this tutorial on how to implement Alfresco behaviours:

https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html

Hyland Developer Evangelist
Bryan-Pauls
Member II

Re: Creating behavior for deleting associated workflow after document deletion

Posting so remember to check incase someone finds a solution.