Variable Syntax for Emails and Scripts
In this topic:
In any text field that supports variables, you can click to open the script editor and select variables for the current context.
Depending on the context, the editor allows you to input a single line or multiple lines.
Multi-line script editor
With the multi-line script editor, syntax highlighting is available for the following:
- Execute embedded script workflow steps
- Execute script workflow steps
- Dynamic list scripts
You can also use keyboard shortcuts to expedite common actions, such as finding and replacing. To see a list of keyboard shortcuts for the multi-line script editor, see Default Keyboard Shortcuts in the Ace documentation.
The basic syntax for using variables in scripts and emails is:
If a variable value may contain spaces, enclose the entire variable in double quotation marks. For example, if a VM's name may contain spaces, use:
When using custom attributes, always enclose the attribute name in single quotes (whether or not the attribute name contains spaces). The attribute name is case sensitive. For example:
When passing a variable to a script that uses named arguments, always enclose both the named argument and the string in double quotes, like this:
"/Computer:This name has spaces".
The following example won't work:
You must use the following syntax instead:
Commander allows you to add both Execute Script and Execute Approval Script steps to workflows. Execute Approval Script steps have a special behavior. If the script output returns exit code 0, the workflow proceeds to the next step; if the script returns exit code 1, the workflow fails, and the request is automatically rejected.
For more information about workflow steps, see Workflow Steps Reference.
For more information about variables that can be used in workflow steps, see Using Variables to Access Commander Metadata for Workflows.
When configuring the command line for Execute Script and Execute Approval Script steps, you must use an absolute path to the executable, even if the executable exists in the Windows path. Otherwise, Java may attempt to execute the command in an incorrect location.
Formatting the email body
<a> tag is automatically added to links in emails (only the http protocol is supported). For example, if the value of a custom attribute is a link, the value will be formatted as a link in the email.
If you don't use HTML markup in the email body, the body is assumed to be plain text; <br> and <p> tags are automatically added for new lines.
If you add HTML markup to the email body, however, no additional tags are added.
Dates returned by variables are of the form yyyy/mm/dd hh:mm:ss.
The scripts or executables that are called will run under the Commander service account. Make sure that this account has the appropriate permissions or the script may fail to run.