- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2021 03:47 PM
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:
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
Solved! Go to Solution.
- Labels:
-
flow designer
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2021 03:56 PM
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);
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2021 03:56 PM
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);
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2021 06:41 AM
Hi
Thank you for your response. Can you give me an example what value to put in the 2nd inputs?
inputs['request_item'] = ; // GlideRecord of table: sc_req_item
What do I put here?
Thank you,
Harriet

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2021 10:21 AM
Heya Harriet,
So for this example it's expecting a gliderecord, or a on object that represents a RITM. How you get this is going to be different but as an example:
var ritmGR = new GlideRecord('sc_req_item');
if(ritmGR.get('sys_id_of_record')){
inputs['request_item'] = ritmGR ; // GlideRecord of table: sc_req_item
}
This does a lookup and gets us a glide record object to pass in. This may be a pill in your flow if you've already done a lookup action to find your RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2021 10:26 AM
Hi
Ahh that worked! Thank you so much for your help!!
Best regards,
Harriet