Anyone successfully use sn_flow_trigger.FlowTriggerAPI.fireCatalogTrigger() to restart RITM Flow?

Mo Lau
Tera Contributor

Hi there,

 

As title, I find this KB https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0859955

However nothing happened after running it.

1 REPLY 1

Isaac Swoboda
Tera Expert

Hopefully you found a solution to this already. But I found the same thing and looking at the documentation it appears that instead we should be using the "FlowAPI". Below is some sample code pulled from Yokahama release. The method is somewhat misleading as it generates a new flow context record. 

FlowAPI - Scoped, Global | ServiceNow Developers

(function() {
  try {
    // You will need to find hte flow context of the RITM you are wanting to restart
    var flowContextID = '4216396ffd7d11107edcf07204c30fd5';     // sys_id of old/errored sys_flow_context record
    var result = sn_fd.FlowAPI.getRunner()            // Create a ScriptableFlowRunner builder object.
      .restartFlowFromContext(flowContextID); // Restart flow

    var contextId = result.getContextId();  // Retrieve the context ID from the result
    var dateRun = result.getDate();

    gs.info(contextId + ' ' + dateRun); // This will give you the NEW flow context record. 

  } catch (ex) {
    var message = ex.getMessage();
    gs.error(message);
  }

})();