How can I restart a Flow on a RITM besides running it as a TEST?

Matt184
Tera Contributor

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

find_real_file.png

7 REPLIES 7

Allen Andreas
Administrator
Administrator

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!

Jay Uttanoor
Tera Contributor

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

Jay Uttanoor
Tera Contributor

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);  
  }
}
})();

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!