How to pass inputs from wrofklow to subflow in flow designer

anvitha ash
Tera Contributor

 

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 🙂 


1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@anvitha ash 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@anvitha ash 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@anvitha ash 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@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 

@anvitha ash 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader