Variables
You can map variables and use variables in expressions. Variables store values that the flow can use at run time in addition to stream data. See below for an introduction to the different kinds of variables in the Flow Service. See the following pages for specifics.
- Flow variables: Get, set, and search variables within the scope of the running flow. Or, pass flow parameters from a parent flow to a child flow.
- External variable sets: Define constants, request variables, session variables, and application variables in .xvar files, which you can share across projects.
- System variables: Get environment information.
- Local variables: Define variables for use with the Velocity, XMLMerge, and XMLUpdate components (local to these components).
- Mapper variables: Set variables in the mapper. For example, increment a variable as each row is processed.
- Stream variables: Get and set additional inputs and outputs in a stream. For example, pass additional inputs to components.
See below to find where to define each variable type or to start from the scenarios you use variables in:
Getting, Setting, and Creating Variables
Start with the following list to find where to create variables:
- Flow variables: To open the Variables pane, open the flow in the workspace. Click an empty space in the workspace to open the flow's properties in the inspector.
- System variables: Click Edit in the main menu and select System Variables.
- External variable sets: Create an external variable set, right-click the .xvar file in the tree pane, and click Edit.
- Local variables, mapper variables, stream variables: Select a component and define properties in the category tabs next to the Basic tab in the inspector. The Flow Service maps the properties in each category tab to stream variables.
In the following sections, you can find standard procedures to get and set variables:
Note
Note the following conditions for a variable name to be valid:
-
You can't use the following characters:
!\"#$%&'()=~^|\\@`+*;:{}[],.<>/?\t -
You can't use a number as the first character.
-
There isn't a limit to the length of the name.
-
Variable names are case sensitive.
-
You can use single-byte spaces and non-ASCII characters.
You can dynamically get and set variables using a Mapper component or expressions.
Mapping Values
You can use a Mapper component to get and set different types of variables:
- To set a variable, link the variable's output field in the mapping window.
- To reference a variable, link the variable's input field of the mapping window.
Referencing Variables in Expressions
You can use variables to build expressions. You can use expressions to set component properties and define conditional expressions for conditional layers in the Mapper.
You can use autocomplete to avoid errors: Type "$" and select an object. Type "." and select an attribute. You can query the following objects to reference variables.
| Variable | Variable reference |
|---|---|
| Flow variable | $flow.<Flow variable name> |
| External variable set | $exvar.<External variable set name>.<variable name> |
| System variable | $system.<System variable name> |
| Stream variable | $stream.<Stream variable name> |
Or, use a getter to reference a non-ASCII variable name:
$flow.get("var1")
Related Tasks
See the user's guide for procedures:
- Set component properties with expressions or with a Mapper component.
- Create conditional layers for Mapper components. To start from creating a mapping, see Mapper Components.
- Create conditional layers for SubFunctions. To start from creating a SubFunction, see Function Collections > SubFunctions.
Automatically Updating References
After you change a variable name, the Flow Designer automatically updates the references in the following places:
- Mappings
- Conditional expressions
- Property expressions
- The templates for the Velocity component under direct input mode
The Flow Designer won't automatically update the references in the following cases:
- If the Velocity component is referencing an external template file (that is, when the Mode property is set to File).
- If you change the variable name when editing the variable in CSV format (such as if you right-click the row for the variable in the Variables pane).