Interacting with adTempus from Scripts

When adTempus runs a script, the script has access to an integration interface that allows the script to exchange information with the adTempus server. For example, the script can retrieve and set Job Variables, set the Checkpoint for the job, and log messages to the Job Log.

Additionally, .NET scripts derive from a base class that exposes a Parameters object, which provides additional context information to the script. See the script overview topic for more information.

The integration interface is exposed to scripts through a global object named "adTempus" ("$adTempus" for PowerShell scripts).

Integration Interface Members

The adTempus object exposes the following properties and methods. For complete information see the Script Integration API Reference.

Properties

Name Description
Checkpoint Gets or sets the Checkpoint for the job.
JobID Gets the unique ID for the job definition.
JobInstanceID Gets the unique ID for this job instance.
JobVariables Gets the Job Variables for the job.
StepID Gets the unique ID for the job step definition.
StepNumber Gets the step number

Methods

Name Description
CaptureFile Overloaded. Captures a file on disk and stores it in the job history.
LogMessage Logs a message to the Job Log for the job.
ReplaceVariableTokens Expands variable tokens in a string
SendNotificationMessage Sends a notification message through the adTempus notification system.
Sleep Delays execution for the specified number of milliseconds.

Message Logging

Scripts can report progress, problems, or other information to be stored in the job history using the LogMessage method. Log messages can be sent to two destinations:

SWhen a script calls LogMessage with the messageType parameter set to MessageTypeEnum.Debug, the message is sent to the Debug Log. All other messages are sent to the Job Log.

If your script logs a large number of messages for debugging purposes, you should use MessageTypeEnum.Debug to send them to the Debug Log rather than the Job Log. Reporting a large number of messages to the Job Log fills the adTempus database (each message is stored as a separate row in the database), and it can be difficult to review the messages in the Console.

If your script already creates a log file using its own logging mechanism, you can use the CaptureFile method to attach that file to the job history.

Examples

The following examples demonstrate how to perform basic operations using the integration interface.

Logging a Message

To log a message to the job history (see discussion above), use LogMessage:

adTempus.LogMessage(MessageTypeEnum.Error,0,"Failed to process import file")

Getting and Setting Job Variables

A script can retrieve and set Job Variables using the JobVariables collection:

myVariable=adTempus.JobVariables("MyVariable")
adTempus.JobVariables("SomeJobVariable")="A value"

When you set a JobVariable this way, the change only applies within this job instance; you are not updating the original definition of the variable. If you need to set a value persistently (so it will be seen by other jobs) use the Job Variable Update Task or Job Variable Update Action.

If you want to persistently update a variable based on a value derived in a script, you must do it in two steps. For example, suppose you need to update the "BatchID" variable for the Job Group.

  1. Have your script place the value in a temporary variable

    adTempus.JobVariables("TempValue")="Batch 4098703"

  2. Include a Job Variable Update Task or Action that sets the "BatchID" for the group from the "%TempValue%" variable token.