- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:28 AM
Hi All,
Hope you are doing good.
I created a simple workflow for demand form, if its in qualified state the workflow will trigger the approvals and move it to next state if approved. But in demand form when Reset to Draft button is clicked the state chances to draft state.
Once the workflow is triggered in qualified state and then reset is draft button is clicked then i need to cancel the existing flow and restart the flow when it moves to qualified again.
I need some help in cancelling and restarting the workflow.
Thanks in advance.
Regards,
vamshi
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:41 AM
HI,
You can use workflow API to achieve this.
Sample Script: You can use this in any server side script i.e. UI action, Business rule etc
var workflow = new Workflow();
//cancel all the workflows, where current is a task record with a workflow context
workflow.cancel(current);
gs.addInfoMessage(gs.getMessage("Workflows for {0} have been cancelled", current.getDisplayValue()));
For detailed information please see API documention at:
cancelWorkflow() | Documentation
RestartWorkflow() | Documentation
Regards,
Muhammad
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:41 AM
HI,
You can use workflow API to achieve this.
Sample Script: You can use this in any server side script i.e. UI action, Business rule etc
var workflow = new Workflow();
//cancel all the workflows, where current is a task record with a workflow context
workflow.cancel(current);
gs.addInfoMessage(gs.getMessage("Workflows for {0} have been cancelled", current.getDisplayValue()));
For detailed information please see API documention at:
cancelWorkflow() | Documentation
RestartWorkflow() | Documentation
Regards,
Muhammad
Muhammad