- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 03:51 AM
Hello,
I have a workflow where I store variable values from RITM variables.
For example, let's say I have a catalog item called ABC. Once the request is submitted, I store some variable values from the RITM of that item, like:
var aa = current.variables.xyz; var bb = current.variables.abc;
Now, I am invoking a Subflow (Flow Designer) using a Run Script activity, and I need to pass the variables aa and bb to the Subflow. These variables need to be used within the Subflow to determine the next steps.
Can someone please guide me on how to pass workflow variables into a Subflow?
Thanks in advance 🙂
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 04:01 AM
something like this
try {
var aa = current.variables.xyz;
var bb = current.variables.abc;
var inputs = {};
inputs['inputVariable1'] = aa;
inputs['inputVariable2'] = bb;
var result = sn_fd.FlowAPI.getRunner().subflow('subflowName').inBackground().withInputs(inputs).run();
var outputs = result.getOutputs();
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
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
01-17-2025 03:56 AM
any reason you created another question when your earlier question is already open and members are responding on it?
I already responded to your earlier question
Please delete this question and continue discussion on the earlier one.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 04:01 AM
something like this
try {
var aa = current.variables.xyz;
var bb = current.variables.abc;
var inputs = {};
inputs['inputVariable1'] = aa;
inputs['inputVariable2'] = bb;
var result = sn_fd.FlowAPI.getRunner().subflow('subflowName').inBackground().withInputs(inputs).run();
var outputs = result.getOutputs();
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
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
01-17-2025 06:08 AM
@Ankur Bawiskar thanks this seems to be good
Stuck again. Another follow up: untill the subflow (flow designer) which we have called from run script, untill the subflow get completed the workflow should not move to the next activity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 06:25 AM
I believe I have answered your original question.
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