The Task Object

A Task object is used for executing a task in the PROIV application environment. In order to use this object you must have a working PROIV application environment.

The Task object allows you to define the task and its environment, execute it and then collect the result set returned by the task.

Task objects are of class Task.

Task Object Properties

Property

Description

collectReports

If this property is set to 'true' it will cause the Task object to collect any PROIV task 'report' output and store it. The default value is 'true' which means ‘report’ output is automatically collected.

delimiter

The code point value of the delimiter character used to do the delimiter split. The default is 44 (a comma).

delimiterSplit

If this property is set to 'true' the Task object will collect PROIV task 'report' output as an array of arrays rather than an array of delimiter separated strings. This is done by converting each row in the PROIV task 'report' output from a delimiter-separated string to an array. If the collectReports property is not true this property will have no affect.  The default value is ‘false’ which means report data will be collected as an array of delimiter separated Strings.

error

An error message If an error has occurred. If no error has occurred then it will be null. The error messages are explained below:

Execute error - The PROIV Task had an error condition. This string will be followed by the error message from the PROIV environment.

parameters

A script object used to hold all the input and output parameters used by the PROIV Task. Parameters are either strings or a single dimensional array of strings.

prototype

A reference to the Object Prototype. This property does not enumerate and can not be deleted but can be changed.

reportOutput

This is a result set from the PROIV Report Task. It is in the form of a array of delimiter separated strings where element represents one line of report output. This property will only be present if the collectReports property is true and the PROIV Task actually produced a report output.

taskName

The name of a PROIV Task. This is the task that will be executed by the Execute function.

Whenever this property is set the parameters property is automatically cleared.

From  PROIV Version 5.5, it is possible to return report data as XML. Active Web will determine whether the report data it receives from PROIV is XML or not. If it is XML then the reportOutput property will contain an XML string rather than an array.

Task Object Functions

Function

Description

execute()

Causes the Task object to execute the PROIV Task using its properties and the parameters set up in the Parameters object. The parameters returned from the PROIV task are put in the Parameters object. Returns true if there were no errors. The error property will contain an error string if there was an error.

nextReport()

Use this function when processing report output from a PROIV task. Returns true if there is a report result set available in the reportOutput property. Returns false if there are no more report result sets.

Using the Task Object

Once a Task object has been created (see the Task Constructor below) you will then need to set any parameters required for the task. The Parameters property holds the Task parameters required for both input to the PROIV Task and output from the PROIV Task.

e.g.

myTask.parameters.TASK_PARAMETER_1 = 22;

myTask.parameters.TASK_PARAMETER_2 = “foo”;

This example sets two input parameters the first called TASK_PARAMETER_1 and the second called TASK_PARAMETER_2.

e.g.

var result1 = myTask.parameters.TASK_PARAMETER_3;
var result2 = myTask.parameters.TASK_PARAMETER_4;

This example shows that a task returned two output parameters when it was executed and these can be obtained from the Parameters property.

Both input and output parameters can be strings or arrays of strings. Whether a parameter is an array or not depends on the PROIV Task. Output parameters will be updated by the Task and an Array parameter can update the whole or part of the array.

A PROIV Task can return report data.  The report data can be collected in the Task object and then retrieved later by setting the Task collectReports property true (its default value). The report data can then be retrieved by calling the Task nextReport() function to prepare the data from the next report (a PROIV Task can return more than one report in a single task) and then accessing the reportOutput property for the report rows.


The Task Constructor

Using the new Operator with the Task Constructor

The Task constructor is used to create new Task objects.

var myTask = new Task(taskName, hostName, codiv, operatorID, operatorPassword[, systemUserName[, systemUserPassword[, environment[, port]]]]);

A new Task object is created using the arguments (these are described below).

 taskName - The name of the PROIV task to be executed.
 host - The DNS name or IP address of the PROIV Kernel Manager machine.
 codiv - The PROIV company/division code to use by the kernel.
 operatorID - The PROIV operator-id to use by the kernel.
 operatorPassword - The password to use for PROIV operator-id.
 systemUserID - (Optional) The operating system user-name to use for security validation by the Kernel Manager.
 systemUserPassword - (Optional) The operating system password to use.
 environment - (Optional) The name of the required kernel environment.
 port - (Optional) The TCP port number (default 5432) to connect to the Kernel Manager.

Shown below is the Task object prototype chain.

Calling the Task Constructor as a Function

When the constructor is run as a function without the new operator it has exactly the same behaviour as using the new operator.

Task Constructor Properties

Constructor properties are read only (they can not be changed or deleted) and it is not possible to add new properties to the Constructor.

Property

Description

prototype

A reference to the Object Prototype. This property does not enumerate and can not be changed or deleted.

Task Constructor Functions

The Task constructor has no predefined functions.

Comment on this topic

Topic ID: 150098