Create Variable Action



See Also

Create AD Group-Setting Properties, Get AD Object Path Action, Get AD Object Property Action, Loop Dataset Action


Creates an AutoMate variable, which can be used to store dynamic values for use in any task step.

Practical Usage

Variables are used as a storage mechanism to store data while a task is running. Once a variable is created, its contents can be viewed, set or modified within subsequent steps. The value of a variable parameter can be specified parameters of at runtime by placing the variable name in percent signs (i.e. %myvarname% will automatically be converted it it's contents at runtime). For more information see Variables.


General Tab

Variable Name

Text, Required
MARKUP: NAME="thecurrentdate"

Specifies the name of the variable to create. It is important that this value is unique, descriptive and does not conflict with any BASIC scripting keywords (examples of names that would cause a conflict include: date, day or week).

Initial Value

Text, Optional - Default (blank)
MARKUP: ...>The current date is %Format(Now())%</AMVARIABLE>


Specifies the value that the variable should be set to initially. As with all parameters, this value may be literal or an expression (if surrounded by percent % signs).


Variable is read-only

Yes/No, Optional - Default no

Specifies that the variable is not able to be set to a value other than that specified in the Initial Value parameter.  Selecting this option is equivalent to creating a task specific constant.

Variable is private

Yes/No, Optional - Default no

Specifies that the variable is only available to the current task and not to sub tasks started with the Start Task action. If this value is left unchecked (default) the specified variable will be available to sub-tasks.


Text, Optional - Default (blank)
MARKUP: ...>The current date is %Format(Now())%</AMVARIABLE>

Specifies the value that the variable should be initially set to. As with all parameters, this value may be literal or an expression (if surrounded by percent % signs).

Treat as parameter

Yes/No, Required

Specifies that the variable will only be created if it does not already exist. This is particularly useful when a task may have parameters passed to it at runtime (that is, variables of the same name will be created automatically) but a default value should be assumed when debugging and parameters are not present.


Text, optional default (none)
MARKUP: DESCRIPTION="This variable holds the date"

An optional text description that describes the purpose of the variable, this information will be displayed at design time in the Debug | Variables information window.

Advanced Tab

Variable Type

Text, Required
MARKUP: TYPE="number"

Causes the variable to assume a specific type.

The available options are:


Using Variables

All variables must be created before they can be used. This is done using the Create Variable <AMVARIABLE> action. Once created, variables can be set using the Set Variable <AMSET> action, or by certain actions that support populating variables. To get data out of the variables, in any action parameter, simply surround the variable name with percentage % signs (e.g. %varname%). Remember not to use percentage signs when specifying the name of a variable to populate, percentage signs are only needed to get data out.

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder


NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<AMVARIABLE NAME="MYVARIABLE">Sets the variable to this value</AMVARIABLE>