- 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
‎10-19-2022 09:45 AM
what will be the trigger of this flow when we will set it up