Cancel and re-run flow designer on a record by script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 02:46 AM
Hello,
In my case i have a workflow who runs on a record waiting for condition, i want to cancel the excecution of this flow designer when a field changes and re-run it from the begining.
How can i proceed ?
Thank you.
- Labels:
-
flow designer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 02:53 AM
HI Moncef,
Open the flow and click on the 3 dots you will get code snippet which will help you to trigger the flow for a record.
To Trigger
inputs['table_name'] = 'sc_req_item';
inputs['request_item'] = 'ritm001'
// Start Asynchronously: Uncomment to run in background.
sn_fd.FlowAPI.getRunner().flow('global.flowname').inBackground().withInputs(inputs).run();
To cancel
sn_fd.FlowAPI.cancel(contextId, 'cancelled');
API details here - https://docs.servicenow.com/bundle/orlando-application-development/page/app-store/dev_portal/API_ref...
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 03:02 AM
Hello Murali,
I want to cancel and re-run it after a field change.
Do you have any ideas ?
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 05:25 AM
HI Moncef,
Instead of cancelling the flow, try to create another flow and use trigger condition - update a record
then jot down your actions. this may work for you. But if you had any approvals in the first flow, then you have to consider adding actions to cancel them.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 03:05 AM
Hi Moncef,
Can you explain your business use-case here?
you need to re-run the flow using a script.
but you have mentioned that you have workflow which runs on that record.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader