How to get the Outputs to a Scripted REST API response from sub flow outputs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 03:34 AM
Hello all,
In a scripted REST API, I am calling a sub flow,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 03:54 AM - edited 05-27-2025 03:55 AM
you are calling subflow from scripted REST API and using foreground run
then you can access the subflow outputs directly
flow designer - How to use subflow outputs in flow script
something like this
// Get the subflow runner
var flowAPI = new sn_fd.FlowAPI();
// Define inputs (if any)
var inputs = {
"input_field_1": "value_1",
"input_field_2": "value_2"
};
// Execute the subflow synchronously
var result = flowAPI.getRunner().subflow('my_subflow_name').inForeground().withInputs(inputs).run();
// Access the outputs
var outputs = result.getOutputs();
// Use the outputs
gs.info(outputs.output_field_1); // Example: Accessing an output variable
gs.info(outputs.output_field_2);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 04:46 AM
Hello ANkur,
Yes, I am calling in the same way you showed in the script.
But I am not getting outputs in the log messages.
Regards,
Lucky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 04:56 AM
then it means you have not configured any output variable
share your subflow how outputs are configured
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader