Initializing complex variables and lists

In Process Designer, you must initialize all complex variables and all lists (arrays) before you can use them in a BPD or service.

About this task

The Coach framework requires that all variables that a Coach or Heritage Coach references are initialized. If the human service does not initialize these variables, the framework does it when the Coach runs. This initialization occurs even if the Coach does not use these variables. Because of this initialization, ensure that service level code does not require variables to be in an undefined state if a Coach references these variables.

Procedure

  1. In the Variables tab of your BPD or service diagram, declare a variable that is a complex business object or a list. For example, a variable named myVariable of type Requisition or a variable named myList that is a list of string variables.
  2. In the diagram area, drag a script task from the palette to the canvas.
  3. In the Implementation tab, initialize your variable using the a JavaScript text area:
    • If the variable is a complex object, use: tw.local.<variableName>=new tw.object.<businessObject>();.

      For example: tw.local.myVariable=new tw.object.Requisition();

    • If the variable is a list, use: tw.local.<listName>=new tw.object.listOf.<businessObject>();.

      For example: tw.local.myList=new tw.object.listOf.String();

    Note: If your complex business object or list includes elements that are complex variables, they also must be initialized.

What to do next

You have initialized your complex variable or list. The variable can now store data.