Defining Set Variables
The 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 and 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:
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, and
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. does not execute the query, and 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.
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.
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. |