Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to trigger a flow once a RITM has been created from a different flow in Flow Designer?

Harriet K
Mega Guru

In Flow Designer, I have the flowing flows:

1. Flow A that contains a script action, which parses through a bulk load request from an Excel attachment. For each row, it generates a RITM and populates the variables with values.

2. For each RITM generated, I want it to run Flow B, which contains actions and subflows.

According to this document, in order to run an action, flow, or subflow, I have to use the FlowAPI method.

Flow Designer has a feature, where you go to the 'More Actions' menu and click on the 'Code snippet' to get the code snippet to execute the flow like so:

find_real_file.png

There are two different code snippets that it provides.

Server side code snippet:

(function() {

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

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

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

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

})();

Client side code snippet:

(function() {

var inputs = {};

inputs['table_name'] = 'Table Name';
inputs['request_item'] = { // GlideRecord
table : 'sc_req_item',
sys_id :
};

GlideFlow.startFlow('scopedapp.flownamehere', inputs)

})();

I tried out both of these code snippets and it did not work. I don't get any error messages.

Note: I am well aware that the client side code snippet requires the 'Callable by Client API' to be enabled, which I already did because I followed this document.

Which of these code snippets do I use to call Flow B from Flow A within a script action?  Please advise how to get this to work.  Thank you!

Best regards,
Harriet

 

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi,

My preference would be to turn flow B into a subflow and call it as such. The server side script is correct but as you're running in async mode I presume you want the output/results? If so, you'd want to capture those in a returned variable.

the outputs var is then the returned values

(function() {

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

var result = sn_fd.FlowAPI.getRunner().flow('scopedapp.flownamehere').inBackground().withInputs(inputs).run();

var outputs = result.getOutputs();


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

})();

View solution in original post

5 REPLIES 5

what will be the trigger of this flow when we will set it up