Job Variables
Job Variables allow you to easily use changeable values in the configuration and execution of your jobs. Job Variables are similar in concept and usage to Windows environment variable: you create a variable, giving it a name and a value. You can then insert the variable (by referencing its name) in various places within adTempus (such as the command line for a program to be executed). When adTempus runs the job, it replaces the reference to the variable with the variable's current value.
For example, supposed you have a job with 8 steps. Each of those steps runs a program that requires as a command-line parameter the name of the folder from which it should read data files. All of the steps use the same folder, which is usually c:\clientdata\inputfiles. However, occasionally you need to do a special run of this job, reading data from a different folder. Without Job Variables, such a change would require you to edit all 8 steps to change the command-line parameters to point to the new location.
With Job Variables, you can create a variable for the job (on the Variables page of the job's properties) named "DataPath" and set the variable to c:\clientdata\inputfiles. In each Job Step, instead of putting the path c:\clientdata\inputfiles in the command-line parameters, you put a reference to the job variable, using this syntax: %DataPath%.
When the job runs, adTempus will replace %DataPath%" with the current value of the "DataPath" Job Variable.
Now when you need to do a special run using a different path you can simply change the value of the "DataPath" variable in one place (in the job's properties) and the new value will be used throughout the job. And if you run the job manually, you can override the "DataPath" variable at runtime without even modifying the job (using the Variables page of the Execute Job window).
You can also use Inline Functions anywhere you can use a Job Variable. Inline Functions let you execute script code and then insert the result.
Job Variable Inheritance
Job Variables may be defined at many levels within adTempus: Server, Job Group, Job Queue, Job, Step, and Trigger. Variables set at a level are inherited by all objects at a lower level: variables set at the Server level are inherited by all Groups and Queues on that server, variables set for a Group are inherited by all Groups and Jobs within that Group, etc.
Inherited Variables can be overridden to change their values. In the previous example the "DataPath" variable was defined for a job. This variable will now appear on the "Variables" page in the properties of each step in the job. If one step needs to use a different value, you can edit the variable for that step only and give it the necessary value.
Using Job Variables
Job Variables can be used throughout adTempus in most places where you enter text that is used in the execution of a job. For example:
- The execution target and command-line parameters for a task.
- Paths for file triggers and conditions.
- Notification message subjects and bodies.
Text entry boxes that support Job Variables have an Insert Variables button () next to them. This button opens the Text Edit Window, which allows you to select variables from a list and insert them into your text.
You can also insert variables by directly typing the name of the variable enclosed in percent signs, like this: %Variable Name%. Variable names are not case sensitive, so you could also enter the variable as: %variable name%.
Variables can also be retrieved and set within scripts and set using the Job Variable Update Task or Job Variable Update Action.
Variable Formatting
For date, time, or numeric variables, you can use standard .NET formatting strings to format the value when you insert it somewhere using a token. For example, suppose you have defined a variable named "ProcessingDate" that you set to the current date at the beginning of your processing cycle. You need to include this value in the command line parameters for several programs that you run, but some of the programs need the date to be formatted differently than others. You can insert the date in yyyy-MM-dd format using this token: %ProcessingDate{yyyy-MM-dd}%. If another program needs the date formatted as MM/dd/yyyy, you can insert it using this token: %ProcessingDate{MM/dd/yyyy}%.
Formatting like this only works if you set the Variable Type properly when you define the Job Variable.