Defining Set Variables

The Set Variables workflow action enables you to define named variable values during workflow design. The values are available to later actions in the same workflow at run time. This action replaces the previous method of creating a custom dialog and script to store a value for a later step.

Subsequent Run Script and Run SQL actions can use the variables. The actions can read the variables explicitly from the registry. The variables are inserted automatically where a #VariableName# placeholder appears in the script or SQL text.

To create a variable configuration:

  1. Add a Set Variables action.
  2. Click ... to open the Set Variables dialog box.
  3. On Configuration, specify this information:
    Name
    Specify a configuration name.
    Variable
    Add one or more variables. Specify the variable name.
    Note: Variable names must be unique within a configuration. The comparison of variable names is case-insensitive. Variable names cannot begin with the reserved prefixes SCRIPTVAR, RUNWORKFLOW, or SCRIPTREG.

    When the action runs, each variable is written to this registry location:

    HKEY_CURRENT_USER\Software\Movex\DMP\CLIENT\CustomVariables

    Value
    Specify the value assigned to the variable. The value can be empty.
  4. Click OK.

Using variables

Variables are stored in the registry. A script can read a variable directly from the registry using the workflow script API:

WF.GetRegKey "CLIENT\CustomVariables", "CustomerName", sVar, ""

When using placeholders, Run Script and Run SQL actions can contain #VariableName# tokens. Before the script or query runs, each token is replaced with the matching variable value from CLIENT\CustomVariables.

The token format uses one # character on each side of the name, for example, #CustomerName#. Text between two # characters is treated as a placeholder only when it is non-empty. The text cannot contain spaces or line breaks. This restriction keeps SQL Server temp-table syntax safe. #TempTable for local tables and ##TempTable for global tables are not treated as placeholders.

Handling missing variables

If you use a placeholder that has no matching variable value, the token remains unchanged as #VariableName#. The system does not replace the token with a blank string. The workflow action fails. Run SQL does not execute the query, and Run Script does not run the script.

An error identifies each missing variable. The error is written to the workflow event log and the client log. For example, the logs contain this error: Error: Set Variables placeholder #CustomerName# has no value set.

The error message distinguishes a missing variable from a misspelled placeholder.

Reset on start

The properties of the Root workflow include the Reset variables on start checkbox. When you select this check box, the workflow clears variables created by its Set Variables actions before the workflow runs.

The check box is selected by default for new workflows. Existing workflows retain their saved settings. The new default setting does not change the behavior of existing workflows.

Troubleshooting

This table shows placeholder issues and their resolutions:

Symptom Cause Resolution
The action fails with “placeholder has no value set.” A preceding action did not set the variable, or the token is misspelled. Verify the action order, the Variable/Value grid, and the token spelling.
The placeholder is displayed in the output. The variable is missing, and the token remains unchanged. Define the variable before the action that uses the variable. Then, run the workflow again.