Working with Variables

Variables enable you to store business logic as named values within an expression.

Using variables can enhance your expressions in several ways:

  • They simplify expression development by letting you store lengthy expression terms so that you can quickly reuse them.
  • They enhance the readability of an expression by using shorter variable names to represent larger blocks of expression logic.
  • They can improve calculation performance by enabling node data to be retrieved once when setting the variable value, and then accessing the cached variable value in other parts of the expression. This is particularly effective when you are evaluating a large collection of nodes multiple times in an expression.

Two types of variables are available in Oracle Fusion Cloud Enterprise Data Management:

  • Global variables are defined at the top level of the expression and can be used anywhere in the expression.
  • Local variables are defined within a specific IF statement and can be used only in that particular statement. These can be useful for conditional logic within your expression.

You can use variables in any expression context, such as for deriving property values, creating custom validations, and creating extract filters.

Defining Variables

Your location in the expression builder determines the type of variable that you define. If you are at the top level of the expression, the variable is defined as a global variable and it can be used anywhere in the expression. If you are within an IF statement, the variable is defined as a local variable and can only be used in that IF statement. The procedure for defining a variable is the same between the two types.

  1. Perform an action:
    • In the Statements section of the palette, drag Define Expression to the editor.
    • Click Insert Statement Insert Statement icon, and select Define Variable.
  2. In the Define Variable dialog box:
    • Enter a name for the variable.
    • Select the variable data type. The following data types are supported for variables:
      • Boolean
      • Date
      • Float
      • Integer
      • Node
      • String
      • String List
      • Timestamp
    • Click OK.

    The variable is created and displayed in the Variables section of the palette.

    Note:

    The Variables section lists all global and local variables. Remember that you can drag local variables only to the statements where they are defined.

Using Variables in Expressions

After you define a variable, you can use it in an expression statement or method.

  • From the Variables section of the palette, drag the variable to an expression term within a statement (such as an IF or RETURN) or to a method.
  • From a statement or a method, click Choose Expression Term choose expression term and use the Variables menu to select the variable to insert.

You can select global variables anywhere in the expression. You can select local variables only with the context of the IF statement where they were defined. For both types of variables, you can only use a variable after you have defined it in the editor.

Assigning Values to Variables

You can assign a value to a variable within an expression. For example, you can define a global variable varDesc to retrieve a node's Description property. Then, in an IF statement you can add logic that says if the node's country is the United States, the assigned value of the variable is the node's Description - US property.

To assign a value to a variable:

  1. Insert the variable that you want to assign a value to.
  2. Click Insert Statement Insert Statement icon, and select Assign Variable.
  3. Select the variable that you want to assign a value to, and then use the expression menu or the dot menu to change the value of the variable as desired. You can assign a literal value, another expression, or another variable to the variable value.

Renaming and Removing Variables

  • To rename a variable, click Statement Actions Statement Actions icon, select Rename, and enter a new name.
  • To remove a variable, click Statement Actions Statement Actions icon, and select Remove.