Building input forms
Every input you declare turns into a field on the run form. Left alone, the form is a plain list of names and text boxes in the order you declared them. That’s fine for you, but it’s not fine for the people who’ll run your workflow from the Orchestrator Client or from a VCF Automation catalog. They need labels, sensible defaults, choices instead of free text, and a clear message when they get something wrong, before the run starts.
This recipe builds Report VMs, a read-only report with five inputs, and shapes its form on the Input Form tab: two tabs, a drop-down filled by an action, a fixed list of choices, a field that only appears when it’s needed, and a validation action that catches a bad regular expression before the run starts.
Getting ready
- The action
com.vcfguide.chapter3/findVmsByNamefrom recipe 3.2. - The folder VCF Orchestrator Guide/Chapter 3 and the action module
com.vcfguide.chapter3. - If you want to see the form in VCF Automation, a project with the workflow published to the catalog. That’s covered in Chapter 8. Everything here works from the Orchestrator Client alone.
How to do it
Write two actions for the form
- In Library > Actions, create the action
listVcenterNamesin the modulecom.vcfguide.chapter3. Give it no inputs and the return typeArray/string:
// Returns the host name of every vCenter registered in the vSphere plug-in, sorted.// id is the host name, such as vc01.vmw.lab; name is the full SDK URL.var connections = VcPlugin.allSdkConnections;var names = [];for (var i = 0; i < connections.length; i++) { names.push(connections[i].id);}names.sort();return names;- Create a second action,
validateNamePattern, with one inputnamePatternof typestringand the return typestring:
// Returns an error message when namePattern is not a valid regular expression,// and null when it is. An empty pattern is left to the Required constraint.if (namePattern === null || namePattern === "") { return null;}try { var test = new RegExp(namePattern);} catch (e) { return "'" + namePattern + "' is not a valid regular expression: " + e.message;}return null;Use id, not name. On 9.1.1, a vCenter connection’s name is the full SDK address, such as https://vc01.vmw.lab:443/sdk, while its id is the host name, vc01.vmw.lab, which is what people expect to pick. The same goes for vm.sdkConnection in step 4.
Create the workflow
- Create the workflow
Report VMsin VCF Orchestrator Guide/Chapter 3 with these inputs and one output:
| Name | Type | Direction |
|---|---|---|
vcenterName |
string |
Input |
namePattern |
string |
Input |
powerState |
string |
Input |
limitResults |
boolean |
Input |
maxResults |
number |
Input |
vmNames |
Array/string |
Output |
- On the Schema tab, add one scriptable task called
Find matching VMs, with all five inputs in andvmNamesout:
var candidates = System.getModule("com.vcfguide.chapter3").findVmsByName(namePattern);vmNames = [];for (var i = 0; i < candidates.length; i++) { var vm = candidates[i]; if (vm.sdkConnection.id !== vcenterName) { continue; } var state = vm.runtime.powerState.value; if (powerState !== "any" && state !== powerState) { continue; } vmNames.push(vm.name + " (" + state + ")"); // maxResults only counts when the person ticked "Limit the results" if (limitResults && maxResults > 0 && vmNames.length >= maxResults) { System.log("Stopped at " + maxResults + " results"); break; }}System.log(vmNames.length + " VMs in " + vcenterName + " match");- Click Save, then Run. The form lists the five inputs by name, as plain boxes in the order you declared them. Close it without running. That’s the starting point.
Lay out the form
- Open the Input Form tab. It has two sub-tabs, Request and Validations. On Request, the designer has three parts: Workflow Inputs and Generic Elements on the left, the form canvas in the middle, and the Properties of the selected field on the right. The first form tab is called General, and every input sits on it, labelled with its description.
- Rename the first tab of the form
What to find. Click Add tab and call the new oneOptions. DraglimitResultsand thenmaxResultsonto theOptionstab. Leave the other three onWhat to find, in the ordervcenterName,namePattern,powerState.

Fill a drop-down from an action
- Select
vcenterName. On the Appearance tab, under Label and type, set Label tovCenterand Display type to DropDown. - On the Values tab, open Value options, set Value source to Orchestrator action, and under Select action choose
com.vcfguide.chapter3/listVcenterNames. - On the Constraints tab, turn on Required.

Offer a fixed list of choices
- Select
powerState. Set Label toPower stateand Display type to DropDown. - On the Values tab, leave Value options on Constant and enter four values:
any,poweredOn,poweredOff, andsuspended. Set Default value toany.
Guide free text with a default, help, and constraints
- Select
namePattern. Set Label toVM name patternand add Custom help:A regular expression, matched without regard to case. Use .* for every VM. - On the Values tab, set Default value to
.*. On the Constraints tab, turn on Required.
Show a field only when it’s needed
- Select
limitResults. Set Label toLimit the results, and check that Display type is Checkbox, the usual display for aboolean. - Select
maxResults. Set Label toMaximum number of VMs. On the Appearance tab, open Visibility and set Value source to Conditional value. An expression appears: set Set value to Yes, and in the If row picklimitResults, choose the comparison for “equals”, and entertrue. Add expression adds another rule. - On the Values tab, set Default value to
50and Step to10. On the Constraints tab, set Minimum value to1and Maximum value to500.
Hiding a field doesn’t empty it, so maxResults may still arrive with its default when the box isn’t ticked. That’s why the script in step 4 checks limitResults before it uses maxResults.

Check the whole form before the run starts
- Open the Validations sub-tab of the input form. Drag an Orchestrator validation from Validation Types onto it, enter the label
Name pattern is a valid regular expression, and choose the actionvalidateNamePattern. - Click Save.

Try it
- Click Run. The form opens on
What to find. vCenter is a drop-down listingvc01.vmw.lab, VM name pattern already holds.*, and Power state showsany. OnOptions, Maximum number of VMs is hidden until you tick Limit the results. - Enter
(vcas the pattern and click Run. The form refuses, and shows the message fromvalidateNamePattern. Change the pattern to^vcand run it again.

How it works
The form isn’t part of the schema. It’s a separate layer, stored with the workflow, that describes how each input is presented and checked. Only workflow inputs can appear on it. Variables never do. The designer also offers generic elements, such as text, drop-downs, and password boxes, that don’t match an input. You can bind them to inputs or use them for the form’s own logic.
Each input’s properties are split over three tabs:
- Appearance: how the field looks and when it’s shown. Label, Display type, Visibility, Read-only, and Custom help.
- Values: what it holds before the person touches it, and what they can choose from. Default value, Value options, and Step.
- Constraints: what counts as a valid value. Required, Regular expression, Minimum value and Maximum value (a number’s value, or a string’s length), and Match text box, which makes a field equal another, as for a password typed twice.
Most properties can take their value from more than one source. Constant is a fixed value. Orchestrator action calls an action, and the designer only offers actions whose return type fits the field. Bind field copies another field. Conditional value picks a value from rules on other fields, as maxResults does for its visibility. Computed value builds a value with simple operators. Computed values aren’t available for plug-in types such as AD:UserGroup.
An action called by the form runs on the Orchestrator server, while the form is open. When its inputs are bound to other fields, it runs again whenever one of them changes, but only once all the fields it depends on hold valid values. That’s how cascading drop-downs work: choose a vCenter, and a second drop-down bound to vcenterName refreshes with that vCenter’s clusters.
A validation on the Validations tab is different. It runs when the person submits the form, and it checks the form as a whole. Orchestrator passes it the fields whose names match its inputs, which is why validateNamePattern’s input must be called namePattern. If it returns a message, the form shows it and refuses to submit. If it returns nothing, the form goes through.
mandatory and Predefined answers, often written as OGNL expressions.There's more
Value options or default value? A drop-down’s choices come from Value options. A common mistake is to put the action under Default value instead, which leaves the drop-down empty. Broadcom KB 428466 describes exactly that.
Labels and values. To show one thing and submit another, such as a cluster’s name while the workflow receives its ID, have the action return Array/Properties, each with a label key for the text shown and a value key for the value submitted.
Array/Properties with label and value keys for a string drop-down. The behaviour is documented for VCF Automation custom forms and confirmed in a Broadcom KB, but not on an Orchestrator page.Keep form actions fast. The person waits while each action runs, and a chain of dependent actions adds up. Keep them to a few seconds. Avoid marking a field Required only because an action uses it, and check inputs for null in the action: an empty field bound to an action input is passed as null, not as an empty string.
Return an empty choice in dependent lists. When a dependent list’s action returns a single value, the form can keep the old selection after the field it depends on changes. Broadcom KB 394722 calls this expected behaviour and suggests returning an extra empty value.
Regular expressions must suit Java and JavaScript. A Regular expression constraint must be valid in both syntaxes. A pattern that only one accepts makes the form show “Some data cannot be retrieved” (Broadcom KB 314888).
Forms in VCF Automation. When you publish a workflow to the VCF Automation catalog, its form comes along, and you can refine it there with VCF Automation’s custom form designer. In VCF Automation 9.0.x, Broadcom KB 450158 reports that a Multi value picker fed by an action fails in the catalog with “Error getting external data 403”. Use a DropDown or Dual List until it’s fixed. Chapter 8 covers publishing.
Report VMs starts with this form, and whether KB 450158 still applies.Don’t trust the form alone. A REST client or a parent workflow can run Report VMs without ever seeing the form. If an input must never be wrong, check it in the workflow as well, as recipe 3.4 does.
See also
- 3.1 Workflow basics, for inputs, variables, and outputs.
- 3.5 Resuming and debugging failed runs, for the same
(vcmistake caught after the run starts. - Broadcom TechDocs (VCF 9): Defining Variables and Parameters and Key Workflow Concepts.
- Broadcom TechDocs (Aria Automation 8.18): Input Form Designer.
- Broadcom KB: 428466 — Custom form drop-down shows no values, 394722 — Dependent fields keep old values, 314888 — Regular expression constraints, 410656 — Actions with the Any return type, and 450158 — Error 403 in the VCF Automation catalog.
- VMware Cloud Foundation blog: Good practices for developing custom forms.
- CloudBlogger, the author’s blog: Orchestrator Forms and Service Broker Forms.
