- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi All,
I am trying to call a flow from workflow using Run flow/subflow/action activity. Flow name has been added but on running the flow i am getting following error.
Please assit.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
that doesn't answer the above question.
Are you calling flow or subflow?
If you are calling subflow then what input it's asking? are you sending that ?
share the screenshots of your subflow
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
Monday
Hi @Nikita50
https://www.servicenow.com/community/developer-forum/how-to-call-a-flow-from-a-workflow/td-p/2563561
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi @Nikita50
did u check these link?
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Please use run script activity in workflow to start the flow
user startFlow function
here is the sample code:
(function() {
var now_GR = new GlideRecord('incident');
now_GR.addQuery('number', 'INC0009009');
now_GR.query();
now_GR.next();
try {
var inputs = {};
inputs['current'] = now_GR; // GlideRecord of table: Incident
inputs['table_name'] = 'incident';
var contextId = sn_fd.FlowAPI.startFlow('global.test_flow', inputs);
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday - last edited Monday
Hi @Nikita50 ,
You can call a flow from a workflow using "Run Script" activity and the sn_fd.FlowAPI class.
Follow the steps mentioned below:
Add a "Run Script" activity: In your Workflow, drag a "Run Script" activity from the Core tab on the palette.
Write the script: Inside the script editor, you'll use the sn_fd.FlowAPI to trigger the Flow.
(function() {
try {
// Define the inputs for your flow
var inputs = {};
inputs['table_name'] = current.getTableName();
inputs['record'] = current; // Pass the current record (e.g., sc_req_item)
// Replace 'global.your_flow_name' with the actual scope and name of your Flow.
var flowName = 'global.your_flow_name';
// Run the flow synchronously. This will make the workflow wait for the flow to complete.
// Use .inBackground() instead of .inForeground() if you want the flow to run asynchronously.
var result = sn_fd.FlowAPI.getRunner().flow(flowName).inForeground().withInputs(inputs).run();
// If you need to check the result or use a value returned by the flow, you can do so here. For example:
// var outputs = result.getOutputs();
// workflow.scratchpad.flow_result = outputs.your_output_variable;
} catch (ex) {
var message = ex.getMessage();
gs.error('Error calling flow from workflow: ' + message);
}
})();
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.