Use variables in automations
Overview
Data Management automations make extensive use of variables to transfer information produced by one step and consumed by a later step.
Automation variables
Automation-level variables are defined for the entire automation. All steps within the automation can access these variables.
To define automation variables:
Right-click the project window of an open automation, and then choose Automation Settings.
Select the Variables tab.
Select rows in the Automation variables grid and enter each Variable, its Type, and Initial value on a separate line.
Steps that produce or consume variable values let you add variables during configuration.
System variables
The following automation System variables are read-only. When used in an expression they must be prefaced with the system prefix.
Variable | Description | Type |
---|---|---|
| Time that the automation run started. |
|
| Date that the automation run started. |
|
| Date-and-time that the automation run started. |
|
| User running the automation. |
|
| Data Management version string, for example |
|
| Name of the automation being run. |
|
| Full path to the automation. |
|
| Directory containing the automation being run. |
|
| Hostname of the Execution Server. |
|
| Last-issued error message. |
|
| Name of the step that last issued an error message. |
|
| Date-and-time when the last error was issued. |
|
| Number of CPU cores enabled on the Execution Server. |
|
| Operating system process ID of the project or automation. Used to create uniquely-named files and tables, using the |
|
| Execution Server operating system. |
|
Add variables during configuration
Many steps let you define a variable as a part of the configuration. For example, the ForEach step can be configured to loop over a series of files and put the name of each file in a variable.
To create and use a variable in one step:
Select New from the list of available variables.
Specify the Name, data Type, and Default value of the new variable.
Use variables in expressions
Both the Branch and Expression steps accept expressions as part of their configurations. Branch uses expressions to determine which branch to signal. Expression uses expressions to set the values of variables.
For example, suppose a ForEach group is looping over files, and is configured to put the current file in the FILENAME
variable.
You can insert an Expression step into that group and configure it to build a new file name.
Expression replacement
You can use automation variables in the configuration of any step setting that accepts text, using the syntax ${expression}
. At execution time, ${expression}
is replaced with the result of evaluating that expression. The expressions can be simple variables like ${FILENAME}
. Or they can be more complex, calling functions like ${FileFromPath(FILENAME)}
. When concatenating strings in this way, use inline syntax and no " + " operator like ${TARGET_DIRECTORY}/${FileFromPath(FILENAME)}
.
Example:
The FileSystem step can move a file from one directory to another.
Example:
You want to put the FileSystem step in a ForEach group that is looping over multiple files, and is configured to put the current file in the FILENAME
variable.
Within the group, you want to move each file found to the target directory. You must also extract the file name from its full path. If you configure the FileSystem step's File pattern setting with the expression ${FileFromPath(FILENAME)}
, you can use it in the ForEach loop:
Every time the ForEach loop finds a file, such as c:/temp/move_files_from/somefile.csv
, it reaches into the FileSystem step and replaces the ${FileFromPath(FILENAME)}
with the results of evaluating that expression, which in this case is somefile.csv
.