Siebel Analytics Scheduler Guide > Using Siebel Analytics Scheduler > Working with Scheduler Job Scripts >

Script Object Methods and Events


Siebel Analytics Scheduler has the following script object methods and Events available.

CreateArray Method

Creates an Array object.

Syntax 1

Set array = CreateArray ()

Syntax 2

Set array = CreateArray ( size )

Syntax 3

Set array = CreateArray ( element0, element1, ..., elementn)

Arguments
Argument
Description
size
A long value that specifies the initial size of the array.
element0 ... elementn
The values to place in the array. This creates an array with the lower and upper bounds of 0 (zero) and n, respectively.
Return Value

Returns an Array object.

Usage

This method is provided only for JScript because local JScript Array objects cannot be passed directly to the Script methods. This method is called to create an array object and pass the array object to Script methods that accept an array as arguments.

The different syntax versions create arrays as follows:

Example

var i;
var array1= CreateArray(2);
for (i = 0; i < array1.Size; i++)
{
   array1(i) = i;
}

   array1.Resize(4);
for (i = 2; i < array1.Size; i++)
{
   array1(i) = i;
}

var array2 = CreateArray(0, 1, 2,3);
for (i = 0; i < array2.Size; i++)
{
   if (array1(i) != array2(i))
   break;
}

DeregisterCancelCommand Method

Deregisters a previously registered cancel method.

Syntax

DeregisterCancelCommand

Usage

Call this method to deregister the most recently registered cancel method after a long operation has completed successfully. You do not need to call this method if the script was canceled.

GetConfigurationValue Method

Returns the value in Siebel Analytics Scheduler configuration relative to the Scheduler's root registry entry.

Syntax

value = GetConfigurationValue(configKey [, subkeyPath])

Arguments
Argument
Description
configKey
A string that specifies the registry key name to return.
subkeyPath
Optional. A string value that specifies the registry path below the Scheduler's root path.
Return Value

Returns a string value.

Usage

GetConfigurationValue() returns the string value for a registry setting relative to Siebel Analytics Scheduler. The configKey and subkeyPath strings must be identical to those in the registry.

GetTempFileName Method

Returns a temporary file name.

Syntax

tfname = GetTempFileName()

Return Value

Returns a string value.

Usage

GetTempFileName() does not create a file. It only provides a temporary file name that can be used to create a file. Files created in job scripts are not deleted automatically when the script terminates.

LaunchProcess Method

Executes a command line in a new process.

Syntax

exitcode = LaunchProcess ( commandLine [, wait, terminateOnCancel] )

Arguments
Argument
Description
commandLine
A string that specifies the command line to execute.
wait
Optional. A boolean value that specifies whether the method should wait for the process to terminate. The default is True.
terminateOnCancel
Optional. A boolean value that specifies whether the method should terminate the process when the script is canceled. The default is True.
Return Value

Returns a long value.

Usage

Call this method to execute a command line in a new process. If wait is set to True, this method returns the exit code returned by the process.

RegisterCancelCommand Method

Registers a method to be called when the script is canceled.

Syntax

RegisterCancelCommand source, methodName [, arguments]...

Arguments
Argument
Description
source
An Object whose method is being registered.
methodName
A String that specifies the method name.
arguments
Optional arguments to be passed into the method.
Usage

Occasionally, an object's method takes a long time to complete. If the job is canceled before the call returns, the script engine still must wait until the call returns. This could potentially take hours and tie up resources. This method solves the problem by registering a method that is asynchronously called by the script engine if the script gets canceled.

Cancel methods should be registered before calling the method that executes a long operation. When the method returns, the cancel method should be deregistered by calling DeregisterCancelCommand().

Good practice is to hide implementation details of a COM object from the caller, having the COM object itself handle all registration and deregistration of cancel commands. Pass an instance of the Script object to the COM object, then call the RegisterCancelCommand() and DeregisterCancelCommand() methods because the Script object implements the IDispatch interface.

ScheduleJobDaily Method

Schedules a new job with a Daily trigger.

Syntax

ScheduleJobDaily name, description, scriptType, script, startDate, startTime, endTime, minutesInterval, daysInterval [, parameters, flags, maxRunTimeMS, maxConcurrentInstances, endDate]

Arguments
Argument
Description
name
A string that specifies the name of the job.
description
A string that specifies the description of the job.
scriptType
A string that specifies the script type associated with the job (either VBScript or JScript).
script
A String that specifies the script code or path (if the nqJobScriptContainsPath flag is set) associated with the job.
startDate
A date value that specifies the date the job is activated.
startTime
A date value that specifies the time the job is activated.
endTime
A date value that specifies the time the job is deactivated.
minutesInterval
A long value that specifies the number of minutes between consecutive job executions.
daysInterval
An integer value that specifies the number of days between job invocations.
parameters
Optional. A string array of parameter values passed to the script. The default is an empty array.
flags
Optional. A long value that specifies the flags associated with the job. For valid settings, see JobFlagsEnum Constants. The default is nqJobNoFlags.
maxRunTimeMS
Optional. A long value that specifies the maximum time, in milliseconds, a job runs before it is terminated. The default is 0 (zero), which means the job can run indefinitely.
maxConcurrentInstances
Optional. A long value that specifies the maximum number of concurrent running instances of this job. The default is 0 (zero), which means no limit.
endDate
Optional. A date value that specifies the time the job is deactivated.

ScheduleJobMonthlyDate Method

Schedules a new job with a Monthly by Date trigger.

Syntax

ScheduleJobMonthlyDate name, description, scriptType, script, startDate, startTime, endTime, minutesInterval, whichDays, whichMonths [, parameters, flags, maxRunTimeMS, maxConcurrentInstances, endDate]

Arguments
Argument
Description
name
A string that specifies the name of the job.
description
A string that specifies the description of the job.
scriptType
A string that specifies the script type associated with the job (either VBScript or JScript).
script
A string that specifies the script code or path (if the nqJobScriptContainsPath flag is set) associated with the job.
startDate
A date value that specifies the date the job is activated.
startTime
A date value that specifies the time the job is activated.
endTime
A date value that specifies the time the job is deactivated.
minutesInterval
A long value that specifies the number of minutes between consecutive job executions.
whichDays
An long value that specifies the days of the month the job runs. For valid settings, see DayEnum Constants.
whichMonths
An integer value that specifies the months the job runs. For valid settings, see MonthEnum Constants.
parameters
Optional. A string array of parameter values passed to the script. The default is an empty array.
flags
Optional. A long value that specifies the flags associated with the job. For valid settings, see JobFlagsEnum Constants. The default is nqJobNoFlags.
maxRunTimeMS
Optional. A long value that specifies the maximum time, in milliseconds, a job runs before it is terminated. The default is 0 (zero), which means the job can run indefinitely.
maxConcurrentInstances
Optional. A long value that specifies the maximum number of concurrent running instances of this job. The default is 0 (zero), which means no limit.
endDate
Optional. A date value that specifies the time the job is deactivated.

ScheduleJobMonthlyDOW Method

Schedules a new job with a monthly by day of the week (DOW) trigger.

Syntax

ScheduleJobMonthlyDOW name, description, scriptType, script, startDate, startTime, endTime, minutesInterval, whichOccurrences, whichDays, whichMonths [, parameters, flags, maxRunTimeMS, maxConcurrentInstances, endDate]

Arguments
Argument
Description
name
A string that specifies the name of the job.
description
A string that specifies the description of the job.
scriptType
A string that specifies the script type associated with the job (either VBScript or JScript).
script
A string that specifies the script code or path (if the nqJobScriptContainsPath flag is set) associated with the job.
startDate
A date value that specifies the date the job activated.
startTime
A date value that specifies the time the job is activated.
endTime
A date value that specifies the time the job is deactivated.
minutesInterval
A long value that specifies the number of minutes between consecutive job executions.
whichOccurrences
An integer value that specifies the occurrences of days of week the job runs. For valid settings, see DayEnum Constants.
whichDays
An integer value that specifies the days of week the job runs. For valid settings, see DayOfWeekEnum Constants.
whichMonths
An integer value that specifies the months the job runs. For valid settings, see MonthEnum Constants.
parameters
Optional. A string array of parameter values passed to the script. The default is an empty array.
flags
Optional. A long value that specifies the flags associated with the job. For valid settings, see JobFlagsEnum Constants. The default is nqJobNoFlags.
maxRunTimeMS
Optional. A long value that specifies the maximum time, in milliseconds, a job runs before it is terminated. The default is 0 (zero), which means the job can run indefinitely.
maxConcurrentInstances
Optional. A long value that specifies the maximum number of concurrent running instances of this job. The default is 0 (zero), which means no limit.
endDate
Optional. A date value that specifies the time the job is deactivated.

ScheduleJobNow Method

Schedules a new job with a Run Now trigger.

Syntax

ScheduleJobNow name, description, scriptType, script [, parameters, flags, maxRunTimeMS]

Arguments
Argument
Description
name
A string that specifies the name of the job.
description
A string that specifies the description of the job.
scriptType
A string that specifies the script type associated with the job (either VBScript or JScript).
script
A string that specifies the script code or path (if the nqJobScriptContainsPath flag is set) associated with the job.
parameters
Optional. A string array of parameter values passed to the script. The default is an empty array.
flags
Optional. A long value that specifies the flags associated with the job. For valid settings, see JobFlagsEnum Constants. The default is nqJobNoFlags.
maxRunTimeMS
Optional. A long value that specifies the maximum time, in milliseconds, a job runs before it is terminated. The default is 0 (zero), which means the job can run indefinitely.

ScheduleJobOnce Method

Schedules a new job with a Run Once trigger.

Syntax

ScheduleJobOnce name, description, scriptType, script, startDate, startTime [, parameters, flags, maxRunTimeMS]

Arguments
Argument
Description
name
A string that specifies the name of the job.
description
A string that specifies the description of the job.
scriptType
A string that specifies the script type associated with the job (either VBScript or JScript).
script
A string that specifies the script code or path (if the nqJobScriptContainsPath flag is set) associated with the job.
startDate
A date value that specifies the date the job is activated.
startTime
A date value that specifies the time the job is activated.
parameters
Optional. A string array of parameter values passed to the script. The default is an empty array.
flags
Optional. A long value that specifies the flags associated with the job. For valid settings, see JobFlagsEnum Constants. The default is nqJobNoFlag.
maxRunTimeMS
Optional. A long value that specifies the maximum time, in milliseconds, a job runs before it is terminated. The default is 0 (zero), which means the job can run indefinitely.

ScheduleJobWeekly Method

Schedules a new job with a Weekly trigger.

Syntax

ScheduleJobWeekly name, description, scriptType, script, startDate, startTime, endTime, minutesInterval, weeksInterval, whichDays [, parameters, flags, maxRunTimeMS, maxConcurrentInstances, endDate]

Argument
Argument
Description
name
A string that specifies the name of the job.
description
A string that specifies the description of the job.
scriptType
A string that specifies the script type associated with the job (either VBScript or JScript).
script
A string that specifies the script code or path (if the nqJobScriptContainsPath flag is set) associated with the job.
startDate
A date value that specifies the date the job is activated.
startTime
A date value that specifies the time the job is activated.
endTime
A date value that specifies the time the job is deactivated.
minutesInterval
A long value that specifies the number of minutes between consecutive job executions.
weeksInterval
An integer value that specifies the number of weeks between job invocations.
whichDays
An integer value that specifies the days of week the job runs. See DayOfWeekEnum values for valid settings.
parameters
Optional. A string array of parameter values passed to the script. The default is an empty array.
flags
Optional. A long value that specifies the flags associated with the job. For valid settings, see JobFlagsEnum Constants. The default is nqJobNoFlags.
maxRunTimeMS
Optional. A long value that specifies the maximum time, in milliseconds, a job runs before it is terminated. The default is 0 (zero), which means the job can run indefinitely.
maxConcurrentInstances
Optional. A long value that specifies the maximum number of concurrent running instances of this job. The default is 0 (zero), which means no limit.
endDate
Optional. A date value that specifies the time the job is deactivated.

OnError Event

Occurs when the script engine encounters a run-time error while executing the script. This is intended for cleanup purposes, but the creative use of try/catch blocks in JScript and proper Error Handling in VBScript are often superior alternatives to using this event.

Syntax

OnError

Usage

The script engine calls this procedure when it encounters a run-time error while executing the script. Define this procedure in your script if you want to perform some cleanup activities before the script terminates, such as deleting temporary files and releasing resources.

Examples

Example in VBScript:

Public Sub OnError()
   LogFile.WriteLine "Encountered a runtime error in the script."
LogFile.Close
End Sub

Example in JScript:

function OnError()
{
   LogFile.WriteLine("Encountered a runtime error in the
   script.");
LogFile.Close();
}


 Siebel Analytics Scheduler Guide
 Published: 11 March 2004