how to check state of an flow when completed and error caught
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 05:02 AM
Hi All
I am trying to trigger an sub flow from UI action. How to get status of the sub flow if it is completed or completed (with caught error). I need this information to process further.
Thank you in advance.
var result = {};
result['condition'] = 'test';
var gst = sn_fd.FlowAPI.getRunner()
.subflow('retrieve_supplier_details')
.inBackground()
.withInputs(result)
.run();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 05:33 AM
your subflow can have output variables defined.
you can get the output of that subflow and proceed further
Also you can use try catch block to handle exception so you know if any error occurred
try{
var inputs = {};
inputs['condition'] = 'test';
var result = sn_fd.FlowAPI.getRunner().subflow('retrieve_supplier_details').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
gs.info(outputs);
}
catch(ex){
gs.info(ex);
}
Also check this link
How to get outputs from subflow by script, when subflow gets into waiting state?
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
02-04-2025 05:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 06:05 AM
if subflow is configured to give outputs you should get it, if you are running the subflow in foreground
share complete script
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
02-04-2025 06:18 AM
This is script calling from UI action
gs.addInfoMessage(' integration inprogress....');
var inputs = {};
inputs['condition'] = 'sys_id=' + current.getUniqueValue();
var result = sn_fd.FlowAPI.getRunner().subflow('retrieve_supplier_details').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
action.setRedirectURL(current);