User guide
Data Integration with Sybase Avaki Studio 69
Using expressions within Avaki Studio
Working with variables
Often you will need to create variables when constructing view models, particularly as
the complexity of the model grows or as you use more advanced operators such as
Iterator. Studio provides you with a JavaScript object named variables, which lets
you store any variables you wish to use across multiple operators. Refer to any vari-
ables using the form variables.<operatorInstanceName>.<variableName>
to guarantee their uniqueness across your model. The “operatorInstanceName”
referred to should be the name of the operator where the variable is declared.
You can either enter the variable names directly in the expressions, or you can use Stu-
dio’s expressions menu to enter the name of any downstream variable. See “The
expressions menu” on page 71 for details on using the expressions menu.
Note Variables that you declare in a given operator are only available (are only
in scope) to operators that are upstream in the flow from that operator. Operators
that are downstream from that operator or on a different branch of the flow can-
not access your variable. If you need to use a variable across multiple branches,
for example, you can declare it in your model’s .jsi file.
Updating variables—some caveats
In the expressions that you enter, it’s fine to update variables defined downstream that
are not control variables. However:
• Don’t try to update variables that are defined upstream—you may see unexpected
results if you change a variable outside of the operator that creates the variable. (All
downstream variables appear in Studio’s expressions menu.)
• If you use a control variable—a counter introduced in and maintained by an Itera-
tor operator, for example—don’t update the control variable inside any operator
other than the one that introduces it.