Using variables in tasks

This section explains how to add variables to your tasks.

HCL Universal Orchestrator features a set of predefined variables you can use in your tasks to ensure higher flexibility.

You create a task definition and add one or more of the predefined variables. The variables are assigned a value when the task runs. You can then retrieve this value and use it in a subsequent task in the same workflow. Table Predefined HCL Universal Orchestrator variables lists supported variables.

In addition to these variables, a number of predefined variables is also available in specific task integrations. These variables are exported by default by the task and no user intervention is required to define them. For more information about how you can retrieve the values of these variables for using them in a subsequent task, see Passing properties from one task integration to another task in the same workflow instance.

You can also define custom variables, for executable task types only, as described in Defining variables with the jobprop utility. You can then use these variables in subsequent tasks, as described in Passing variables set by using jobprop in one task to another in the same workflow instance.

The structure of the variable name reproduces the path to the variable in the task context. For example, the jobs.job_name.wa.logon variable is stored in the following path in the example at the end of this topic:
...
 "jobs" : {
    "JOBVAR" : {   
      "wa" : {
        "jobDef" : "/TASKVAR",
        "wksId" : "b4b2068f-0022-4dec-ab01-eb1e48b3b041",
        "logon" : "[wauser]",
...
Table 1. Predefined HCL Universal Orchestrator variables
Variables you can specify in task definitions Description
jobs.job_name.wa.actualStart Date of the submitted task.
jobs.job_name.wa.key Fully qualified name of the task (UNISON_JOB).
jobs.job_name.wa.start Input arrival time of the task.
jobs.job_name.wa.logon Credentials of the user who runs the task (LOGIN). Applies only to backward-compatible tasks.
jobs.job_name.wa.name Name of the submitted task.
jobs.job_name.wa.runid UNISON_JOBNUM
jobs.job_name.wa.wks Name of the workstation on which the task is defined.
js.id ID of the workflow that includes the task (UNISON_SCHED_ID).
js.name Name of the workflow that includes the task (UNISON_SCHED).
js.wks Name of the workstation on which the workflow that includes the task is defined.
To refer to a variable in the current task, you can replace the jobs.job_name notation listed in Predefined HCL Universal Orchestrator variables with a shorter notation, as follows:
$this().wa.variable_name
When defining in a subsequent task a variable to be retrieved from a previous task, use the following notation:
${jobs.job_name.wa.variable_name}
The following example illustrates a workflow named WFVAR containing two tasks (TASKVAR and TASKVAR2) in which TASKVAR2 retrieves the value of some variables defined in TASKVAR. When TASKVAR runs, the variables it contains are assigned a value and this value is then used by the TASKVAR2 task:
SCHEDULE WS_AGT_0#WFVAR 
:
WS_AGT_0#TASKVAR
 TASK
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jsdl:jobDefinition xmlns:jsdl="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdl" xmlns:
jsdle="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdle" name="executable">
    <jsdl:application name="executable">
        <jsdle:executable interactive="false">
            <jsdle:script>echo 'name: ${$this().wa.name}'
echo 'wks: ${$this().wa.wks}'
echo 'js.name: ${js.name}'
echo 'js.wks: ${js.wks}'</jsdle:script>
            <jsdle:credential>
                <jsdle:userName>wauser</jsdle:userName>
                <jsdle:password>${password:}</jsdle:password>
            </jsdle:credential>
        </jsdle:executable>
    </jsdl:application>
</jsdl:jobDefinition>
 RECOVERY STOP


WS_AGT_1#TASKVAR2
 TASK
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jsdl:jobDefinition xmlns:jsdl="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdl" xmlns:
jsdle="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdle" name="executable">
    <jsdl:application name="executable">
        <jsdle:executable interactive="false">
            <jsdle:script>echo 'logon: ${jobs.TASKVAR.wa.logon}'</jsdle:script>
            <jsdle:credential>
                <jsdle:userName>wauser</jsdle:userName>
                <jsdle:password>${password:}</jsdle:password>
            </jsdle:credential>
        </jsdle:executable>
    </jsdl:application>
</jsdl:jobDefinition>
 RECOVERY STOP
 FOLLOWS TASKVAR 

END
The resulting task context is as follows:
{
  "_this": "jobs.TASKVAR",
  "js": {
    "defId": "4c05f44c-937f-4ad0-b7b5-1b09be647e38",
    "wksId": "b4b2068f-0022-4dec-ab01-eb1e48b3b041",
    "name": "/JSVAR",
    "schedTime": "2023-02-15T11:00:10.823Z",
    "id": "60bd2dcd-4d85-479f-901e-f8fffed18607",
    "wks": "/WS_AGT_0"
  },
  "jobs": {
    "TASKVAR": {
      "wa": {
        "jobDef": "/TASKVAR",
        "wksId": "b4b2068f-0022-4dec-ab01-eb1e48b3b041",
        "logon": "[wauser]",
        "name": "TASKVAR",
        "rerunNum": 0,
        "id": "c8dba305-90fd-4950-965f-efc5f07db2c8",
        "jobDefId": "deab69a4-e2d4-405f-853b-9bf9e08f1f65",
        "wks": "/WS_AGT_0"
      }
    },
    "TASKVAR2": {
      "wa": {
        "jobDef": "/TASKVAR2",
        "wksId": "f0e04e03-aa27-4b20-9f5e-40eb5bf66b82",
        "logon": "[wauser]",
        "name": "TASKVAR2",
        "rerunNum": 0,
        "id": "44439148-be6e-41cd-bc84-f0093e47e481",
        "jobDefId": "3daae93c-6279-4af9-91cd-ae2a1807f306",
        "wks": "/WS_AGT_1"
      }
    }
  }
}