Constants

What are constants?

Like variables, constants are used to identify data in a task. However, unlike a variable, a constant is an identifier whose associated value is "fixed", therefore, it cannot typically be altered by a task during its execution. The elements of a constant consists of a name and value. A constant's defined value is global, thus, are available to all tasks on a particular system. When you modify a constant's value, every occurrence of that value is updated across the system.

Constants are useful for defining values that are used often but may change over time or modifying multiple instances of a value at one time. For example, you could create a constant named AdminEmail and assign the network administrator's email address as the value. You could use this constant in multiple tasks where you wanted to send an email notification to the network administrator. If you wanted to run such a task at another location with a different network administrator, you would set up a constant of the same name at the other location and assign it whatever value you wanted. If the network administrator's email address changed, you would simply change the value of the constant.

Creating & defining constants

You can create and define constants from the server or agent level within the Server Management Console:

  1. Server level

    1. From Server Management Console's navigation bar, select Options .

    2. Select Server Settings > Constants.

  2. Agent level

    1. From Server Management Console's navigation bar, select System .

    2. Select the Task Agents, Process Agents, or Agent Groups folder.

    3. Right-click the agent object, and then select Properties > Constants.

To create and define a constant, see Constants Settings.

NOTE: To avoid conflicts with Basic key words, functions or instructions, include distinguishing characters in their names. For example, you could start all constant names with "Const". Also, if you use many constants, you may want to use the names to categorize them. For example, you could begin all email address constant with "ConstEmail" and begin all file location constants with "ConstFile."

Behavior

Constant behavior varies depending on where it was created from.

  • Server Level Constants - Constants created from the Server level are accessible to all available Agents, thus are displayed along with the list of constants created from the Agent properties and appear in bold. Server created constants cannot be deleted or modified from the Agent properties. Server level constants appear in italic and associated with a unique icon.

  • Agent Level Constants - Constants created from the Agent properties of a specific agent can only be accessed by the Agent that the constant was created under. They can be edited or deleted only from that specific Agent as well. These constants are not recognized by the server and therefore, not populated in the server’s list of constants. Agent level constants appear non-italic and are associated with an "A" icon.

NOTE: All constants that appear dimmed specifies that the constant is disabled.

Using constants

Constants may be used in any step parameter by specifying the name of the constant surrounded by percent (%) signs. For example, if a constant named BackupFolder was initially created and given the value of an existing directory used to normally backup files to, in order to specify this directory as the destination in a 'Copy File' action, simply enter %BackupFolder% in the  Destination parameter of this action.

To add a constant in an action using the Expression Builder

  1. From the properties dialog of an action, click inside any entry box, and then select Insert Expression/Variable which appears next to any entry box that accepts expressions.

  2. From the Expression Builder window that appears, select the folder labeled Constants from the list of folders located in the bottom left pane.

  3. Double-click a selection from the list of the defined constants for the local machine that are populated in the bottom right pane. This populates the top pane with the selected item. The selected item will be automatically surrounded with percent signs upon insertion, therefore, there is no need to surround the item with percent signs at this point.

  4. Select Insert to properly insert the constant and close the Expression Builder window. For further information, see Expression Builder.