Build Advanced Expressions

When creating conditions for business rules, you may find your conditions are more complex than you can achieve using the basic condition builder. If this occurs, you can build your own custom expressions to suit your needs.

Note:

If you use advanced expressions in the condition builder, you will no longer be able to use the basic condition builder. If you have already defined some conditions in the basic condition builder, they will be displayed as actions in the Advanced Expression editor.

To create an advanced expression:

  1. Click Use Advanced Expression in the condition builder.

    The Advanced Expression editor has a Design mode, which you use to visually create an expression, and a Code mode where you can type the expression. You toggle between modes using the Design and Code buttons in the header.

    This image below shows Design mode, which has an Actions palette on the left, a canvas in the middle, and a Properties pane on the right:



  2. Drag an action from the palette and position it on the canvas.

    Visual Builder Studio includes some basic actions in the palette to help you build expressions. The palette might also contain additional custom functions that have been added to the extension. For example, if Oracle developers have added any global functions to the extension, like Add Numbers or Multiply Numbers, they are listed under Functions in the palette Like the basic actions, you can drag the functions from the palette into the expression, and configure them in the Properties pane. (In Advanced mode, you can add your own global functions. See Add JavaScript Modules As Global Functions.)



    Let's take a look at what happens when we drag an If action onto the canvas:



    When the If action element is selected on the canvas, the Properties pane contains a Description field and a condition builder.

  3. Define the action in the Properties pane and on the canvas.
    1. Edit the action's properties in the Properties pane. The properties displayed in the Properties pane vary according to the action.

      For an If action, the Properties pane has a condition builder for selecting the condition's criterion, operator, and value. Click + Condition in the Properties pane to add a condition. Right-clicking a condition opens an options menu for adding, moving, and deleting the condition. You can also reposition a condition using drag-and-drop in the condition builder.

      You can use the condition builder's toggle buttons to switch between the Design and Code views:



    2. On the canvas, drag actions from the palette (for example, Return, Assign Variable, Try Catch) into the action's Add Action drop target.

      For an If action, you need to define what happens when the condition is true. If the condition is true, and you want to return from the advanced expression, drag a Return action into the action's drop target:



      Now select the Return action on the canvas, and then select 'true' in the Payload dropdown list in the Properties pane:



  4. Repeat steps 2 and 3 to add more actions to the expression.

    As you add more actions, you can reorganize the order by grabbing the front of the action element on the canvas, and then moving it into a new position:



    Right-clicking an action on the canvas opens a popup menu with some convenient shortcuts, including deleting the action and switching to Code view:



    At any point, if you're comfortable typing expressions you can click Code in the header to open the editor's Code mode. In Code mode you can type your expression directly, and take advantage of the code completion in the editor:



  5. Confirm that the payloads for your Return actions are correct.
    When a Return action is selected on the canvas, you can choose a payload in the dropdown list in the Properties pane.
  6. When you're finished building your expression, click Save.

When you look at your rule, the condition looks like this if it's created using the expression editor: