:PUBLISH

Use the :PUBLISH script statement to convert script variables and arrays into object variables. The :PUBLISH script statement is similar to the :PSET statement because both can pass object variables to parent tasks. However, they differ in the following ways:

  • You can convert arrays to object variables with :PUBLISH.
  • :PSET creates script variables if they do not already exist, whereas :PUBLISH does not. Therefore, you must ensure that any script variables you call in your :PUBLISH statements already exist, or use the :SET statement to create them beforehand.

Syntax

:PUB[LISH] Variable name [, [Object variable] [, Scope]]

Parameters

Parameter Description Format Allowed Values Default Value
Variable name

Name of the script variable or script array to convert.

Follow the standard rules for variable names. For more information, see Variable Names.

For arrays, include empty brackets [] at the end of the name.

Script variable n.a. n.a.
Object variable

(Optional) Name of the new object variable, without a leading ampersand (&).

For arrays, do not specify the empty index brackets at the end of the variable name.

AE name n.a. The Variable name is used if you omit this parameter.
Scope

(Optional) Specifies the tasks within which the variable can be used.

Keyword
  • TOP
    The object variable is passed on to the top Workflow.
  • TASK
    The object variable is only available for its own task.
  • WORKFLOW
    The object variable is passed on to the parent Workflow.
TOP

Important Considerations

Keep the following rules and behaviors in mind when working with the :PUBLISH statement:

  • The script variable or array that you specify must already exist. A runtime error occurs if the specified script variable or array is missing.
  • System performance may suffer if you use a script array containing a very large number of elements (10,000 or more).
  • For performance reasons, the system publishes arrays using only their filled size. For example, if an array is empty and all entries contain an assigned null string, nothing is published. If an array has 5 entries but the last 2 entries are null strings, only the first 3 entries are published to subsequent tasks. Consequently, the size of the array in the subsequent task is limited to 3.
  • Empty elements at the end of an array are neither used in nor removed from the object variable, even if you convert the script variable or create a new object variable.

Examples

In the following example, the SYS_ACT_ME_NAME function retrieves the object name and stores it in a script variable called &CHILD#. The :PUBLISH statement includes the WORKFLOW parameter to ensure that the parent workflow can also utilize the script variable.

:SET &CHILD# = SYS_ACT_ME_NAME()

:PUBLISH &CHILD#,,"WORKFLOW"

The following example defines a script array and populates it with values directly from a VARA object. The script then passes the array to the top workflow as an object variable.

:DEFINE &ARRAY#, string, 5

: FILL &ARRAY#[] = GET_VAR(VARA.TEST, KEY1)

:PUBLISH &ARRAY#[], VARA_ARRAY#, "TOP"

See also: