5.5

Table Of Contents
How to create a workflow that runs a workflow on an array of objects in a loop of workflow elements is
demonstrated in “Develop a Complex Workflow,” on page 102.
How to run a workflow in a scripted For loop is demonstrated in “Workflow Scripting Examples,” on
page 136.
Implement the Start Workflows in a Series and Start Workflows in Parallel
Workflows
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
1 In the workflow schema, add a scriptable task element or an action 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.
2 Link the scripted element or action and bind the input and output of the scripted element or action to
workflow inputs or attributes.
For example, you can bind the vmFolder input of the getAllVirtualMachinesByFolder action to a
workflow input parameter and the actionResult output to a workflow attribute in the calling
workflow.
3 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);
}
4 Bind the inputs and outputs of the scriptable task element to workflow attributes.
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 attribute as an array of Properties objects.
5 Add a workflow element to the workflow schema.
Developing with VMware vCenter Orchestrator
62 VMware, Inc.