You can use the Start workflows in a series and Start workflows in parallel workflows to run a workflow on a selection of objects.
You cannot run the Start workflows in a series and Start workflows in parallel workflows directly. You must include them in another workflow that you create. To use the Start workflows in a series and Start workflows in parallel workflows to run a workflow on a selection of objects, you must obtain the objects on which to run the workflow. You pass these objects and any other input parameters that the workflow requires to the workflow as an array of properties. The Start workflows in a series and Start workflows in parallel workflows emit the results of running the workflow on the selection of objects as an array of WorkflowToken objects.
You implement the Start workflows in a series and Start workflows in parallel workflows in the same way. The Start workflows in a series workflow runs the workflow on each object sequentially. The Start workflows in parallel workflow runs the workflow on all the objects simultaneously.
Prerequisites
Open a workflow for editing in the workflow editor.
Procedure
- In the workflow schema, add a Scriptable task or an Action element to obtain a list of objects on which to run the workflow.
For example, to run a workflow on all the virtual machines in a virtual machine folder, you can add the
getAllVirtualMachinesByFolder action to the workflow.
- Link the scripted element or action and bind the input and output of the scripted element or action to workflow inputs or variables.
For example, you can bind the
vmFolder input of the
getAllVirtualMachinesByFolder action to a workflow input parameter and the
actionResult output to a workflow variable in the calling workflow.
- Add a Scriptable task element to cast the list of objects into a properties array.
For example, if the objects on which to run the workflow are an array of virtual machines,
allVMs, returned by the
actionResult output of the
getAllVirtualMachinesByFolder action, you can write the following script to cast the objects into a properties array.
propsArray = new Array();
for each (var vm in allVMs) {
var prop = new Properties();
prop.put("vm", vm);
propsArray.push(prop);
}
- Bind the inputs and outputs of the scriptable task to workflow variables.
In the example scriptable task element in step 3, you bind the input to the
allVMs array of virtual machines and you create the
propsArray output variable as an array of
Properties objects.
- Add a Workflow element to the workflow schema.
- Select either of the Start workflows in a series or Start workflows in parallel workflows and link the workflow element to the other elements.
- To run on the objects, bind the wf input of the Start workflows in a series or Start workflows in parallel workflow to the workflow.
For example, to remove any snapshots of all the virtual machines returned by the
getAllVirtualMachinesByFolder action, select the
Remove all snapshots workflow.
- Bind the parameters input of the Start workflows in a series or Start workflows in parallel workflow to the array of Properties objects that contains the objects on which to run the workflow.
For example, bind the
parameters input to the
propsArray variable defined in step 4.
- (Optional) Bind the workflowTokens output of the Start workflows in a series or Start workflows in parallel workflow to a variable in the workflow.
- (Optional) Continue adding more elements that use the results of running the Start workflows in a series or Start workflows in parallel workflow.
Results
You created a workflow that uses either of the
Start workflows in a series or
Start workflows in parallel workflows to run a workflow on a selection of objects.