Skip to main content
Skip table of contents

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:

  1. Right-click the project window of an open automation, and then choose Automation Settings.

  2. Select the Variables tab.

  3. Select rows in the Automation variables grid and enter each Variable, its Type, and Initial value on a separate line.

image-20240326-180845.png

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

StartTime

Time that the automation run started.

Time

StartDate

Date that the automation run started.

Date

StartDateTime

Date-and-time that the automation run started.

DateTime

User

User running the automation.

TextVar(256)

Version

Data Management version string, for example 9.5.1.

TextVar(256)

AutomationName

Name of the automation being run.

TextVar(256)

AutomationPath

Full path to the automation.

TextVar(1000)

AutomationDirectory

Directory containing the automation being run.

TextVar(1000)

ExecutionServerName

Hostname of the Execution Server.

TextVar(256)

LastError

Last-issued error message.

TextVar(10000)

LastErrorStepName

Name of the step that last issued an error message.

TextVar(100)

LastErrorDateTime

Date-and-time when the last error was issued.

DateTime

CPUCores

Number of CPU cores enabled on the Execution Server.

Int(4)

ProcessID

Operating system process ID of the project or automation. Used to create uniquely-named files and tables, using the ${} syntax.
Example: ${ "f:/temp/myfile" + system.ProcessID" }

Int(4)

OS

Execution Server operating system.

TextVar(256)

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:

  1. Select New from the list of available variables.

  1. 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.

image-20240326-181246.png

You can insert an Expression step into that group and configure it to build a new file name.

image-20240326-181315.png

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.

image-20240326-181835.png

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.

image-20240326-181902.png

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:

image-20240326-181950.png

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.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.