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 06:41 AM
did you print the outputs?
Is the subflow getting triggered? did you verify that?
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();
gs.info('outputs is' + outputs);
action.setRedirectURL(current);
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:45 AM
yes it is updating record after sub flow is triggered when any errors causing issue as we need to log those errors
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 06:59 AM
you can query sys_flow_context table with the flow name and see the state is error
did you try to give something wrong in subflow purposely and use try catch block to know if it throws any error?
Thank you for marking my response as helpful.
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 07:00 AM
did you try using try catch block as per what I mentioned earlier?
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 07:07 AM
yes but no error message.