com.smartgwt.client.util.workflow

## Class ScriptTask

- java.lang.Object
- - com.smartgwt.client.core.BaseClass
  - - com.smartgwt.client.util.workflow.ProcessElement
    - - com.smartgwt.client.util.workflow.Task
      - - com.smartgwt.client.util.workflow.ScriptTask

- All Implemented Interfaces:
    com.google.gwt.event.shared.HasHandlers
  Direct Known Subclasses:
    StartProcessTask

      public class ScriptTask
      extends Task

  Task that executes arbitrary code, either synchronous or asynchronous. Override the `execute()` method to provide custom logic.

- - ### Field Summary

    - ### Fields inherited from class com.smartgwt.client.core.BaseClass

      `config, configOnly, factoryCreated, factoryProperties, id, scClassName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ScriptTask()`
    `ScriptTask(com.google.gwt.core.client.JavaScriptObject jsObj)`
    `ScriptTask(java.lang.String ID)`
    `ScriptTask(java.lang.String ID, ProcessElement nextElement)`
    `ScriptTask(java.lang.String ID, java.lang.String nextElement)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.google.gwt.core.client.JavaScriptObject` | `create()`
    `java.lang.Object` | `execute(java.lang.Object input, Record inputRecord)` Execute the task.
    `java.lang.Object` | `getInputData()` Get the inputs to this task as specified by `Task.inputField`.
    `Record` | `getInputRecord()` Get all inputs to the task as specified by the `inputFieldList`, as a Record.
    `java.lang.Boolean` | `getIsAsync()` Whether the script task is asynchronous.
    `static ScriptTask` | `getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)`
    `java.lang.Boolean` | `getPassThruOutput()` Does this processElement pass through output from the last executed task (i.e.
    `Process` | `getProcess()` Get the process executing this task instance.
    `protected void` | `onInit_ScriptTask()`
    `protected void` | `onInit()`
    `ScriptTask` | `setIsAsync(java.lang.Boolean isAsync)` Whether the script task is asynchronous.
    `void` | `setOutputData(java.lang.Object taskOutput)` Set the task output as specified by `outputField`.
    `void` | `setOutputRecord(Record outputRecord)` Set all outputs of the task as specified by the `outputFieldList`, by providing a Record.
    `ScriptTask` | `setPassThruOutput(java.lang.Boolean passThruOutput)` Does this processElement pass through output from the last executed task (i.e.

    - ### Methods inherited from class com.smartgwt.client.util.workflow.Task

      `getInputField, getInputFieldList, getOutputExpression, getOutputField, getOutputFieldList, setInputField, setInputFieldList, setOutputExpression, setOutputField, setOutputFieldList`

    - ### Methods inherited from class com.smartgwt.client.util.workflow.ProcessElement

      `completeElement, convertToJavaScriptArray, executeElement, getBindOutput, getClassDescription, getDescription, getDynamicValue, getEditorType, getElementDescription, getForceSingle, getID, getJsObj, getMockMode, getNextElement, getOrCreateJsObj, getProcessElements, getSupportsMultipleInputRecords, getTextFormulaValue, getTypeTitle, isCreated, objectReferencesLastTaskOutput, reset, setAttribute, setBindOutput, setClassDescription, setDescription, setEditorType, setForceSingle, setID, setJavaScriptObject, setMockMode, setNextElement, setSupportsMultipleInputRecords, setTypeTitle, updateGlobalIDInCriteria, updateGlobalIDInValueProperty, updateGlobalIDInValues, updateGlobalIDReferences, updateLastElementBindingReferences, updateLastElementInCriteria, updateLastElementInValueProperty, updateLastElementInValues`

    - ### Methods inherited from class com.smartgwt.client.core.BaseClass

      `addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setFactoryCreated, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ScriptTask

          public ScriptTask()

    - #### ScriptTask

          public ScriptTask(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### ScriptTask

          public ScriptTask(java.lang.String ID)

    - #### ScriptTask

          public ScriptTask(java.lang.String ID,
                            java.lang.String nextElement)

    - #### ScriptTask

          public ScriptTask(java.lang.String ID,
                            ProcessElement nextElement)

  - ### Method Detail

    - #### getOrCreateRef

          public static ScriptTask getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### create

          public com.google.gwt.core.client.JavaScriptObject create()

      Overrides:
        `create` in class `Task`

    - #### setIsAsync

          public ScriptTask setIsAsync(java.lang.Boolean isAsync)
                                throws java.lang.IllegalStateException

      Whether the script task is asynchronous. A synchronous task is expected to return data directly from execute() and is considered complete once the execute() method exits.

      An asnychronous task is expected to start processing in execute(), and will not be considered complete until either `setOutputData()` or `setOutputRecord()` is called.

      Parameters:
        `isAsync` - New isAsync value. Default value is false
      Returns:
        `ScriptTask` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### getIsAsync

          public java.lang.Boolean getIsAsync()

      Whether the script task is asynchronous. A synchronous task is expected to return data directly from execute() and is considered complete once the execute() method exits.

      An asnychronous task is expected to start processing in execute(), and will not be considered complete until either `setOutputData()` or `setOutputRecord()` is called.

      Returns:
        Current isAsync value. Default value is false

    - #### setPassThruOutput

          public ScriptTask setPassThruOutput(java.lang.Boolean passThruOutput)
                                       throws java.lang.IllegalStateException

      Does this processElement pass through output from the last executed task (i.e. transient state)?

      See `taskInputExpressions` for details on the transient state outputs.

      Note that this property does not affect the task at all but is an indicator to the user and to the workflow editor of the behavior of the task as coded (See `Process.passThruTaskOutput()`).

      Overrides:
        `setPassThruOutput` in class `ProcessElement`
      Parameters:
        `passThruOutput` - New passThruOutput value. Default value is false
      Returns:
        `ScriptTask` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### getPassThruOutput

          public java.lang.Boolean getPassThruOutput()

      Does this processElement pass through output from the last executed task (i.e. transient state)?

      See `taskInputExpressions` for details on the transient state outputs.

      Note that this property does not affect the task at all but is an indicator to the user and to the workflow editor of the behavior of the task as coded (See `Process.passThruTaskOutput()`).

      Overrides:
        `getPassThruOutput` in class `ProcessElement`
      Returns:
        Current passThruOutput value. Default value is false

    - #### execute

          public java.lang.Object execute(java.lang.Object input,
                                          Record inputRecord)

      Execute the task.
      Parameters:
        `input` - the task input
        `inputRecord` - the task input record if an `inputFieldList` was specified. See `TaskIO`
      Returns:
        the task output. For multiple field output, call `setOutputRecord()` instead, and return null

    - #### getInputData

          public java.lang.Object getInputData()

      Get the inputs to this task as specified by `Task.inputField`.

      For a task with a `inputFieldList`, use `getInputRecord()` to get access to other inputs.

      Returns:
        input data
      See Also:
        `TaskIO overview and related methods`

    - #### getInputRecord

          public Record getInputRecord()

      Get all inputs to the task as specified by the `inputFieldList`, as a Record.
      Returns:
        input data
      See Also:
        `TaskIO overview and related methods`

    - #### getProcess

          public Process getProcess()

      Get the process executing this task instance.
      Returns:
        the owning process

    - #### setOutputRecord

          public void setOutputRecord(Record outputRecord)

      Set all outputs of the task as specified by the `outputFieldList`, by providing a Record.
      Parameters:
        `outputRecord` - output record
      See Also:
        `TaskIO overview and related methods`

    - #### setOutputData

          public void setOutputData(java.lang.Object taskOutput)

      Set the task output as specified by `outputField`.

      NOTE: for an asychronous task, calling `setOutputData()` indicates the task is complete. For a task with `multiple outputs`, call `ScriptTask.setOutputRecord` instead.

      Parameters:
        `taskOutput` - task output

    - #### onInit_ScriptTask

          protected void onInit_ScriptTask()

    - #### onInit

          protected void onInit()

      Overrides:
        `onInit` in class `ProcessElement`