Table of Contents

Search

  1. Preface
  2. Overview, Downloading, and Installing
  3. Administration API
  4. Identity Service API
  5. Screenflow Programming and SDK
  6. ActiveVOS WSHT API
  7. Embedding Request Forms in Standalone Web Pages
  8. XML-JSON for Process Central

7. APIs, SDKs, and Services

7. APIs, SDKs, and Services

Accessing AeTask

Accessing AeTask

The
AeTask
class (in
ae-avc-tasks.js
script) is a wrapper for the
<taskInstance />
element. This wrapper provides getters and setters for frequently used properties.
One way to get an instance of
AeTask
is by using the
AeTaskApi.getInstance(...)
function:
// ... // setup AE_ACTIVEVOS_ENGINE_URL etc. // ... var taskApi = new AeTaskApi(); taskApi.getInstance( "urn:b4p:1235", // task ID function(aTask) { // handle success response // aTask is an instance of AeTask (see ae-avc-tasks.js). alert( "Got task, id: " + aTask.getId() ); alert( "Task name: " + aTask.getName() ); alert( "Task status: " + aTask.getStatus() ); // aTask.getJson() returns the underlying raw JSON data structer. // aTask.getOwner() returns current owner. }, function(aJsonFault) { alert("Fault!"); }, function(aStatusCode, aStatusMessage) { alert("Transport error: " + aStatusCode + " " + aStatusMessage); } );
Refer to
AeTask
in
ae-avc-tasks.js
for additional functions and details. Getters and Setters to task input/output data are described below:
Functions that you can use are:
  • getInputPart
  • getOutputPart
  • setOutputPart
getInputPart(aPartName)
Returns the task input part data given the part name (per WSDL message). If the
aPartName
is not given, the first available part is returned.
// // Task is an instance of AeTask, obtained via AeTaskApi.getInstance(...) // (assuming using the Loan Approval human task example) // // <message name="WshtLoanInput"> // <part name="request" element="loan:loanProcessRequest" /> // </message> // <message name="WshtLoanOutput"> // <part name="response" element="loan:loanApprovalResponse" /> // </message> var loanRequestInput = task.getInput("request"); // 'request' is the part name // Note: task.getInput() returns first available part since part name is not given. alert("Firt Name = " + loanRequestInput.loanProcessRequest.firstName); alert("Loan Amount = " + loanRequestInput.loanProcessRequest.amountRequested);
getOutputPart(aPartName)
Returns the task out part data given the part name (per WSDL message). If the
aPartName
is not given, the first available part is returned. If part data is not available,
null
is returned.
var loanOutput = task.getOutput("response"); // 'response' is the output part name // check for null in case output is not set. if (loanOutput != null) { alert("Approved? = " + loanOutput.loanApprovalResponse.responseToLoanRequest); }
setOutputPart(aPartName, aPartData)
Sets the output part data in the
AeTask
instance (in-memory). This method does not 'save' (invokes WSHT
setOutput
on the server). To save, you must either use
AeTask.saveOutputParts
(preferred) or
AeTaskApi.setOutput(...)
.
// First time use, create JSON output: // var loanOutput = { {"loanApprovalResponse" : ... }}; // or getOutput() to access current value if the output has already been set. var loanOutput = task.getOutput("response"); // modify data AE_JSON_NODE_UTIL.setText(loanOutput.loanApprovalResponse.responseDescription, "Some Text"); // Set output (in-memory only) task.setOutput("response", loanOutput); // Now, save all available parts to the server using the AeTaskApi. var taskApi = new AeTaskApi(); task.saveOutputParts( taskApi, function(aSetOutputResponse) { // success (json data) }, function(aFaultResponse) { // fault (json data) }, function(aStatusCode, aStatusMessage) { //error } );