Expressions: Detailed Example

This detailed example further illustrates how to use the expression builder to build custom business logic.

See these topics for more information about the expression builder:

In this example, we want to be able to drag nodes from an Account dimension in an Oracle Financials Cloud General Ledger application to an Account dimension in a Corporate Planning application. In order to do that, we have set up a node type converter between the node types in each application. (For more information about converting node types, see Working with Node Type Converters). We will build the following expression to transform the Account Type property in the Planning application:

If the account type in the Oracle Financials Cloud General Ledger application is "Asset", "Liability", or "Owner's Equity", we want the account type property in the Corporate Planning application to be "Expense". If it is any other kind of account type, we want the Corporate Planning account type property to be "Non-Expense".

First, let's look at the properties in the node type converter that we set up:

  1. From Node Types, click the Account node type for Corporate Planning to open the node type in the inspector.
  2. Click the Converters tab.
  3. In the Properties to Copy panel, locate the Account Type property in the Target column.
  4. Click Edit.
  5. In the Operation column, select Transform from the drop down menu.
  6. In the Source column, click Define Expression define expression (or define expression depending on your theme).
    node type inspector with Transform and Define Expression highlisted
    .

    The expression builder is displayed.

Next we will build the expression to transform the account type.

Building the Expression

To build the transformation expression:

  1. From the palette, in Statements, drag the IF statement to the blue arrow at the top of the editor.
    expression builder with IF statement dragged to editor
  2. From Operators, drag two OR operators to the IF condition in the editor.
    editor with three IF statements separated by OR operators

    Notice that each of the IF statements and the statement block have red outlines around them. This means that they are not valid. Each IF statement has a condition that is expected to be of type Boolean, and each statement block is expected to contain an return statement. The expression builder evaluates the expression in real-time as you build it, and these validation errors will be resolved as we continue to add fields to our expression.

  3. In the first IF condition, click Choose Expression term, and then select sourceNode from the drop down menu.
    IF statement with Choose Expression Term highlighted and source Node displayed
  4. Click the dot next to sourceNode, and select properties from the drop down menu.
    IF condition showing sourceNode, the dot to click, and properties

    Note:

    When you click the dot next to a field in an expression, the drop down menu displays only the objects, methods, and attributes that are applicable to that field.
  5. Click the dot next to properties, and select FCGL.Account Type from the drop down menu.
    properties dropdown with all of the relevant properties displayed

    Note:

    When displaying properties for property transformations, because the node type of the source node is known, only the properties for that node type are displayed. However, when displaying properties for derived properties, because the node type is not known, all of the properties that are valid for the application are displayed.
  6. Select the dot next to FCGL.Account Type, and select equals from the drop down menu.
    If expression now reads sourcenode properties FCGL Account Type equals

    Notice that the red validation border is no longer displayed on the first IF condition. This is because by adding an equals statement, the condition now contains the required Boolean value.

  7. In the literal text field, enter "A" (for Asset).
    Literal field showing that A has been entered
  8. Repeat steps 3-7 to add IF conditions for FCGL.Account Type equals "L" (for Liability) and "O" (for Owner's Equity).
    IF statement shows the three conditions detailed in the step

    All of the IF conditions now contain Boolean values and therefore no longer display red borders indicating validation issues. However, the statement block is still missing a return statement. Thus, it still has a red border indicating a validation error.

  9. In the statement block, click Insert Statement and then select return from the drop down menu.
    statement block with a return statement highlighted

    Notice that after you add the return statement, the red validation border is no longer displayed around the statement block.

  10. In the return block, enter "Expense".
    return statement shows Expense entered in text field
  11. In the lower return block, enter "Non-Expense".
    second return block displays Non-Expense

    Note:

    You do not have to manually enter an Else If statement after the first IF statement. If an IF statement is not evaluated as True, the logic continues to the next statement automatically.
  12. Click Apply.

    The expression builder is closed and the node type inspector is displayed.