Trigger flow from a workflow in scope

Nora3
Kilo Expert

Hi!

I was wondering if it's possible to trigger a flow from a workflow (the flow and the workflow is in the same scope as I am working in). How can I run a flow in the workflow?

 

Thanks.

 

1 ACCEPTED SOLUTION

siva_
Giga Guru

Hello Nora, 

 

Here is the blog shared by Dave , which would help you to call a flow from a server side script, As you say that you wanted to call a flow from a workflow , the API shared by Dave which is introduced in London Release Of servicenow Should help you achieve your requirement. 

Note : Only available for instances in London or newer versions .

 

Thanks,

Siva 

 

Mark this response as correct/helpful if that really helps

 

View solution in original post

6 REPLIES 6

shanedavis
Tera Expert

Great helpful article!  It works except for the issue below.  Any help is appreciated!

I copied the Code snippet like @Mattias Johnsson, but had to change inputs['request_item'] = ; to inputs['request_item'] = current; because it was giving a syntax error like it was copied.  Looking at my workflow, the run script is running successfully with a State of Finished, but the workflow is not proceeding past this Run Script box.  Any ideas of how I can fix this?

Disregard.  You comment out the "Start Asynchronously" line and uncomment the line for "Execute Synchronously".

(function() {

    try {
        var inputs = {};
        inputs['table_name'] = 'Table Name';
        inputs['request_item'] = current; // GlideRecord of table: sc_req_item 

        // Start Asynchronously: Uncomment to run in background.
        // sn_fd.FlowAPI.getRunner().flow('global.shane_test').inBackground().withInputs(inputs).run();

        // Execute Synchronously: Run in foreground.
        sn_fd.FlowAPI.getRunner().flow('global.shane_test').inForeground().withInputs(inputs).run();

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

})();