trigger a subflow from scripted rest api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 07:34 AM
Hi all,
I want to trigger a subflow from a scripted rest api so that i can get the output of that subflow stored in some variable.
If this is possible please guide me with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 07:44 AM
Hello @Akshay Jugran ,
try doing this
try {
var inputs = {};
inputs['input_name'] = ; //pass your input accordingly
var result = sn_fd.FlowAPI.getRunner().subflow('subflow_name').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
You need to run this script by passing your inputs accordingly and result will be stored in "outputs" variable
Hope this helps
Mark the answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 07:28 AM
In this case, where I want to call the flow from the script, what should I set as trigger while creating the flow in servicenow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2025 10:07 AM
Thanks,
this solution works to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 09:25 AM
Hello @Akshay Jugran,
You can call a sub flow using the "Copy Code Snippet" functionality of Flow. Please find the image below, which will guide you on how to create a code snippet.
Hope this helps!
Please mark this answer as correct if it assists you.
Thank you!