How can I restart a Flow on a RITM besides running it as a TEST?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2021 11:59 AM
We use Flows for most of our catalog items (Ordering software, AD groups, Access, etc) and occasionally the flow will stop. This might be from an error or just simply timing out. We currently have to go back into the flow and hit TEST (screenshot below) and then enter the RITM number to rerun the flow against that request. I'd like to find a way that we could do this perhaps in a script (and provide a list to restart) or even a UI Action menu. Is it possible to do something like this? Thanks for the help!
-Matt
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2021 02:24 PM
Hi,
You can use the FlowAPI to cancel a flow and re-run, etc: https://docs.servicenow.com/bundle/paris-application-development/page/app-store/dev_portal/API_refer...
You can check this post and the last response which was by Sachin for assistance as well: https://community.servicenow.com/community?id=community_question&sys_id=87d21e8edb1300506064eeb5ca96...
This will give you an idea on what to do.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2022 02:34 PM
Hi Matt,
Where you able to find a solution to run the restart or Cancel for a Catalog Item Flow, looks like the API documentation would work for Flows related to Table. Any information please share here.
Regards,
Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2022 03:11 PM
Found a solution that worked for me, instead of inputs['current'] had to give inputs['request_item']
hope this is helpful
(function() {
var grScReqItem = new GlideRecord('sc_req_item');
grScReqItem.addEncodedQuery("Query");// provide a Query
grScReqItem.orderBy('sys_created_on');
grScReqItem.setLimit(1);
grScReqItem.query();
while (grScReqItem.next()) {
try {
var flow = grScReqItem.cat_item.flow_designer_flow;
var flowName = flow.sys_scope.scope + "." + flow.internal_name;
var inputs = {};
inputs['request_item'] = grScReqItem; // GlideRecord of table: sc_req_item
inputs['table_name'] = 'sc_req_item';
var contextId = sn_fd.FlowAPI.startFlow(flowName, inputs);
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 07:30 AM
Hi,
I believe it depends on the context, if you're not trying to adjust the current object, then yea, you'd need to use something else.
In any case, glad you got something working for yourself.
If my initial reply above helped...please mark it as Helpful.
Take care! 🙂
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!