Use Script Output as Input to Workflow Steps
When you capture the output of a script step as a comment, you can use the script's output or exit code as the input to a subsequent step in the workflow.
The following step types allow script output as input:
- Set Custom Attribute step: Use script output to set a custom attribute value for a VM. The Set Custom Attribute step can be used in completion workflows and command workflows.
- Any type of email step: Use script output to populate the Address List field.
The following variables are available:
#{steps[x].output}
#{steps[x].exitCode}
Where x is a step number (beginning at 1) or a step name. For example, to use the output of the third step in a workflow, add this syntax to a subsequent step in the workflow:
#{steps[3].output}
Example: Use script output to set a value for a custom attribute
The following is an example of a completion workflow, where:
- Step 1 is an Execute Script step that backs up a VM and records the time of the backup. In addition, step 1 is configured to capture the script output as comment.
- Step 2 is a Set Custom Attribute step that sets a value for the preconfigured custom attribute "Last Backup Time". You can use the output from step 1 (the time of the last backup) as input for the custom attribute value.
Example: Use script output to populate an email address
The following is an example of an approval workflow, where:
- Step 1 is an Execute Script step that queries the Active Directory for the email address of the requester's manager. In addition, step 1 is configured to capture the script output as comment.
- Step 2 is a Send Approval Email step. You can use the output from step 1 (the email address of the requester's manager) as input for the Address List field.
To see how this functionality fits into an end-to-end example, see Create Command Workflows with Custom Attributes.