I need to cancel workflow programmatically when folder is updated, I can use the rule to call script, but I have no idea how to write script, that will stop workflow that was started for this folder.
Can somebody help me with it?
This is how I can do it
for each ( wf in document.activeWorkflows ) { workflow.getInstance(wf.id).remove(); }
If it is important, this is my script to start workflow
var date = new Date(new Date().getTime()); date.setMinutes(date.getMinutes()+20); var workflow = actions.create('start-workflow'); workflow.parameters['bpm:workflowDueDate'] =date; workflow.parameters.workflowName = 'activiti$validationProcess'; workflow.parameters['bpm:workflowDescription'] =date.getHours()+":"+date.getMinutes()+". Check "+document.name; workflow.parameters['bpm:assignee']=people.getPerson("admin"); workflow.parameters['sendEMailNotifications'] = false; workflow.execute(document);