AnsweredAssumed Answered

Delete Associated Workflows after document has been deleted

Question asked by abbask01 on Dec 4, 2018
Latest reply on Dec 5, 2018 by abbask01

I have a requirement that if a document has been deleted in the repository then all the workflow that are associated with it should get deleted (each workflow package will always have a single document). Originally, on delete of a document the workflow is left in a hanging state and the reference of the document gets removed from the workflow side (bpm_package).


I tried to implement this by using rule/action (items are deleted or leave this folder) - was able to find workflows in js and cancel them, but it does not delete the document nor the workflow. on checking the XHR request i was able to find out that a concurrency exception occurs between the action and onDelete policy.


how do i delete/cancel/close the associated workflows of a document


PFB script to cancel workflow



* js function call on 'onDeleteNode' to cancel all running workflows


function cancelWorkflow() {

   var document = behaviour.args[0];
   logger.warn("doc: " +;

   document.activeWorkflows.forEach(function(activeWf) {
         activeWf.cancel(); / / also tried activeWf.delete();