Pass variables using Parallel Flow Launcher

gldecurtins
Mega Expert

Hi all

I do want to trigger a sub-workflow out of a workflow. The workflow shall pass two parameters to the sub-workflow. How can this be achieved?

Input 1: action, select box, choices('create','update','delete');

Input 2: CI, list collector pointing to cmdb_ci

The Parallel Flow Launcher should trigger one sub-workflow for every CI selected in the list collector.

I did check the "Scrpt Workflow" checkbox. Inputs seems to be quite static, isn't it?

javascript:

coordinator = new WorkflowCoordinator( {workflow:'Workflow - Sub'} );

for (var i = 0; i < current.variables.var_list.length; i++) {

      coordinator.add( {u_action: 'delete'} )

      coordinator.add( {u_cmdb_ci: current.variables.var_list[i]} )

      workflow.debug(current.variables.var_list[i]);

}

coordinator;

While testing the workflow the Parallel Flow Launcher fails: "Cannot start: no flows or already running? flows: 0, running: 0".

What is the proper way to trigger n sub-workflows passing multiple inputs?

Cheers

-Luca.

1 ACCEPTED SOLUTION

russ_sarbora
ServiceNow Employee
ServiceNow Employee

I'm not sure which field you have this script in, Inputs or Workflow script field that appears after checking the Advanced checkbox? Make sure its in that Workflow script field, and you'll need to take out the javascript: line



Also, your loop is adding 2 subflows to the coordinator every pass through. I think what you want to do is add 1 subflow with 2 inputs.


coordinator.add( {


  u_action : 'delete',


  u_cmdb_ci : current.variables.var_list[i]


});




It should look something like this:



Screen Shot 2015-02-12 at 11.48.30 AM.png


View solution in original post

5 REPLIES 5

ritaaudi
Tera Contributor

Hi: Where do you declare the inputs (such as u_action & u_cmdb_ci mentioned here) in the sub workflow? I'm not seeing where that's done. Thank you.