Use Advanced Expressions to Control a Page Display

Use Application Composer's expression builder and write Groovy scripts to set conditions for page layouts. For example, an expression on a page layout can prevent users from updating a particular field based on the value of an opportunity.

Note: You can't add an expression condition to landing page (list page) custom layouts.
Tip: You can also control the display of pages using choice list values (using a record type field) and roles. The record type and role conditions are convenient, declarative ways of attaching conditions to a layout. Thus, supply an expression to control the display of a layout, only if the record type and role conditions don't meet your needs.

To write an expression for a page layout:

  1. In Application Composer, expand the object in the object tree, and select the Pages node.

  2. On the Application Pages tab, find the type of page layout that you want to create.

    For example, to write an expression that controls the display of a creation page, in the Creation Page Layouts region, select the standard layout and click the Duplicate Layout icon. Then, make changes to the duplicate custom layout.

  3. Note: The first custom layout that you create from a standard layout is called the default custom layout, but you can change the name. Oracle recommends that you don't add conditions to the default custom layout. You can add an expression, and all other conditions, to the next custom layouts that you create.
  4. After editing and saving the layout, under the Advanced Expression column, click the calculator icon to open the expression builder.

  5. Write an expression that describes the conditions required for this layout to appear at runtime.

    • If your script references one or more fields, then select those fields in the Depends On choice list, too. If those field values change at runtime, then the expression is reevaluated and the page layout is refreshed if the new condition is met.

      For example, let's say you write this script:

      PartyName == 'abc' || NoteTypeCode == 'GENERAL'

      Your script references two fields. Thus, you must select those fields, Author and Type, in the Depends On choice list, which appears at the top of the expression builder.

      Note that long text fields don't work like other fields. If your script references a long text field, such as Note Text, then you must use the toString() operator in your script. For example:

      If(NoteTxt?.toString() == 'abc')

      Remember to select the Note Text field in the Depends On choice list, too.

    • Your expression should return either a True or False value. At runtime, Application Composer interprets a True value to mean that the condition was met.

      Let's look at the following examples:

      • Let's say you want to display a specific page layout if the Win Probability for an opportunity is 95. In this case, your script could be:

        if (WinProb==95)
        {
        return true;
        }
        else
        {
        return false
        }
      • In another example, let's say you want to show or hide some fields from the layout based on the category ID value. In this case, your script could be:
        if([300000018675471,300000018675472].contains(Cate
        goryId)){
        return false;
        }
        else 
        { 
        return true 
        }

Examples of Page Layouts that Appear Based on Expressions

  • Don't allow users to add a revenue item or a product to an opportunity, after a quote has been generated and approved, or while an opportunity is in approval.

  • Control the display of page layouts based on the user's location, language, or device.

  • Write an expression to combine multiple conditions.