Scope of variables and variable override order
Variables of the same name specified at different scope levels may override one another. Variables set at an inner subflow scope override those set at an outer subflow scope. This variable override order also applies to default values of input variables.
For example, consider the following flow and job scope levels:

- If the J0 job sets a flow variable A=100, the variable is visible to the main flow MF scope and all subflow scopes (including SF). Therefore, J1, J2, and J3 will all use A=100.
- If J1 sets A=50, J2 will use A=50 because the variable set at the MF_SF subflow scope overrides the variable set at the main flow MF outer scope. However, J3 still uses A=100 because the value at the main flow MF scope is still A=100. J2 uses A=50 even if J0 sets A=100 after J1 sets A=50.
This variable override order also applies to default values of input variables. For example,
- If main flow MF has an input variable IV with a default value of 200, and SF does not have input variables, J0, J1, J2, and J3 will all use IV=200.
- If subflow SF now has the same input variable IV with a default value of 20, J0 and J3 will use IV=200, while J1 and J2 will now use IV=20.
- If J0 sets IV=30, it overrides the default value at the MF scope, but not at the MF:SF subflow scope. Therefore, J1 and J2 will use IV=20, while J3 will use IV=30.
- If J1 sets IV=5, J2 will use IV=5, while J3 still uses IV=30.
Similarly, if you submit a flow with variables, the variables will only override the default values at the main flow level, but not the default values at subflows. However, if you specified no default values in the subflow, then the specified values are also visible to the subflow.
The variables set by the job have similar scope to variables in any programming language (C, for example). If the job sets the variable in JS_FLOW_VARIABLE_LIST (or in the file specified by JS_FLOW_VARIABLE_FILE) within a subflow, the scope of the variable is limited to the jobs and events within the subflow. This means that the variable is only visible to that subflow and is not visible to the main flow or any other subflows. If the same variable is overwritten by another job within the subflow, the new value is used for all subsequent jobs or events inside that subflow.
If the job sets variables in the file specified by JS_PARENT_FLOW_VARIABLE_FILE within a subflow, the user variable is passed to the parent flow.
Flow variable values override global variable values. Similarly, a value set within a subflow overrides any value set at the flow level, only within the subflow itself.
Environment variables are set in the job definition and the job runs with the variables that are set.
If you use ppmsetvar to set user variables and you use ppmsetvar multiple times, the variables will be appended. For example, if you run the following, the end result will be a=10, b=2, c=7, and d=100:
ppmsetvar -f a=1 b=2
ppmsetvar -f a=10 c=7
ppmsetvar -f d=100
If you use ppmsetvar in conjunction with other methods of setting user variables in Process Manager, such as a variable file or job starter, note that the variable file can override any variables set with ppmsetvar as it is read last.
Subflows inserted in other flows and linked
When specifying input variable values for linked subflows, the same rules apply because the specified values are effectively treated as default values of the input variables.