run subworkflows in a workflow

Snow Tomcal
Tera Expert

HI, 

I am trying to run multi workflows asynchronously from run script activity in a different workflow. we tried to use sn_fd.FlowAPI but nothing happened 

attaching the script-

for(var i=0; i<5; i++){

sn_fd.FlowAPI.getRunner().flow('global.flow_name').inBackground().withInputs(input_object).run();

}

I am looking at the workflow history and nothing happens.

Thank you!! 

 

6 REPLIES 6

Amit Verma
Kilo Patron
Kilo Patron

Hi @Snow Tomcal 

 

If I understood correctly, you want to run another flow from your parent flow. If Yes, you can make use of Create Code Snippet Utility and then try calling your flow.

 

https://www.servicenow.com/community/developer-forum/how-to-launch-a-flow-from-a-script/m-p/1370964

 

AmitVerma_0-1704880030824.png

 

Thanks & Regards
Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Stefan Georgiev
Tera Guru

Hello @Snow Tomcal,

I am not sure if your case is a flow or a workflow that you want to execute by a script, you are using the flow API if you want to call a workflow please try what was explained in this question:

https://www.servicenow.com/community/developer-forum/run-workflow-from-background-script/m-p/1904248

var gr = new GlideRecord('table');

gr.initialize();

gr.insert();

var wflw = new Workflow();
wflw.startFlow(wflw.getWorkflowFromName('give the workflow name'), gr, 'insert');

Hope that this helps you!

If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.

All the Best,
Stefan

thank you!

is there a way to send to the workflow a variable?