Using the Context object with Actions

The context object provides an interface for your script to interact with WhatsUp Gold.

All methods and properties are retrieved using the Context namespace.

Note: You may need to remove the copyright information from the cut and paste if it appears when you copy from this help file.

Method

Method description

LogMessage(sText);

This methods allows for a message to be written to the WhatsUp Gold debug log. Messages are displayed in the Event Viewer.

Example

JScript

Context.LogMessage( "Checking action name using Context.GetProperty()");

VBScript

Context.LogMessage "Checking Address using Context.GetProperty()"

SetResult(LONG nCode, sText);

This method allows for a result code and result message to be set. This is how you can tell the WhatsUp Gold system if the action succeeded or failed.

Example

JScript

Context.SetResult(0, "Script completed successfully."); //Success
Context.SetResult(1, "An error occurred."); //Failure

VBScript

Context.SetResult 1, "An error occurred."

NotifyProgress(sText);

This method allows for a message to be written to the actions progress dialog. Messages are displayed in the Test dialog and Running Actions dialog.

Example

JScript

Context.NotifyProgress( "Checking action name using Context.GetProperty()");

VBScript

Context.NotifyProgress "Checking Address using Context.GetProperty()"

IsCancelled();

This method tests whether the action has been cancelled by the user. If the return is true, then the script should terminate.

A cancel can be issued by the user in the action progress dialog and by the WhatsUp Gold engine when shutting down.

GetProperty(sPropertyName);

This property offers access to many device specific aspects. You obtain access to these items using the names listed. Theses names are case sensitive.

"ActionName"

The action display name

"Address"

The IP Address of the device

"Name"

Network name of the device

"DisplayName"

Display name of the device

"DeviceID"

The device ID

"ActionTypeID"

The action type ID

"TriggerCondition"

The reason the action was fired.

Trigger values:

 1 Monitor changed from DOWN to UP
 2 Monitor changed from UP to DOWN
 4 A Passive Monitor was received...
 8 The "Test" Button was hit
16 This is a recurring action...
32 Device is UP
64 Device is DOWN

Example

JScript

var sAddress = Context.GetProperty("Address");
var nDeviceID = Context.GetProperty("DeviceID");

See Also

Scripting Actions

Example Active Script Actions