Cancel workflow with web-script

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

Cancel workflow with web-script

Jump to solution

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?

1 Solution

Accepted Solutions
biker89
Active Member II

Re: Cancel workflow with web-script

Jump to solution

This is how I can do it

for each ( wf in document.activeWorkflows )
{
     workflow.getInstance(wf.id).remove();
}

View solution in original post

2 Replies
biker89
Active Member II

Re: Cancel workflow with web-script

Jump to solution

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);‍‍‍‍‍‍‍‍‍‍
biker89
Active Member II

Re: Cancel workflow with web-script

Jump to solution

This is how I can do it

for each ( wf in document.activeWorkflows )
{
     workflow.getInstance(wf.id).remove();
}