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:
- From Node Types, click the Account node type for Corporate Planning to open the node type in the inspector.
- Click the Converters tab.
- In the Properties to Copy panel, locate the Account Type property in the Target column.
- Click Edit.
- In the Operation column, select Transform from the drop down menu.
- In the Source column, click Define Expression
.
.The expression builder is displayed.
Next we will build the expression to transform the account type.
Building the Expression
To build the transformation expression:
- From the palette, in Statements, drag the IF statement to the blue arrow at the top of the editor.
- From Operators, drag two OR operators to the IF condition in the editor.
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.
- In the first IF condition, click , and then select sourceNode from the drop down menu.
- Click the dot next to sourceNode, and select properties from the drop down menu.
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. - Click the dot next to properties, and select FCGL.Account Type from the drop down menu.
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. - Select the dot next to FCGL.Account Type, and select equals from the drop down menu.
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.
- In the literal text field, enter "A" (for Asset).
- Repeat steps 3-7 to add IF conditions for FCGL.Account Type equals "L" (for Liability) and "O" (for Owner's Equity).
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.
- In the statement block, click and then select return from the drop down menu.
Notice that after you add the return statement, the red validation border is no longer displayed around the statement block.
- In the return block, enter "Expense".
- In the lower return block, enter "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. - Click Apply.
The expression builder is closed and the node type inspector is displayed.