Previous Next JavaScript must be enabled to correctly display this content

## 15.6 Understanding Application Computations

Create an application computation to set the value of a single page or application-level item. Application computations run at the same point across multiple pages in an application.

Tip:

To learn more about execution behavior in the case of a validation error, see What Happens When a Validation Fails?

- About Application Computations
  Application Computations are units of logic that set the value of a single page or application-level item and are run at the same point across multiple pages in an application.
- About Application Computations that Execute On New Instance
  Use the On New Instance Computation Point to retrieve information once within a user's session.
- Creating an Application Computation
  Create an application computation from Shared Compoents.
- Copying or Subscribing to Application Computations
  Copy application computations from the current application or from another application. When copying an application computation from another app, you can also subscribe to it.
- Subscribing to an Application Computation
  Subscribe to an application computation on the Application Computations, Create / Edit page.
- Accessing the Application Computation History Report

Parent topic: Managing Computations, Validations, and Processes

### 15.6.1 About Application Computations

Application Computations are units of logic that set the value of a single page or application-level item and are run at the same point across multiple pages in an application.

Similar to page-level computations, application computations can be based on static values, item values, PL/SQL, or SQL. A common use of an application item is to store the value of the last page viewed in the application. By storing the value in an item, you can add a back button and then redirect the user to the page number captured by the computation. This type of computation works well, for example, when you need to enable users to back out of an error page.

Example: Storing the Last Visited Page

The following is an example of a computation that stores the last page visited. In this example, the computation:

- Stores the last application page visited to an item named `LAST_PAGE`

- Checks that the value of a `CURRENT_PAGE_ITEM` is of type PL/SQL Function Body with a Computation body of:

      BEGIN
         :LAST_PAGE := nvl(:CURRENT_PAGE,:APP_PAGE_ID);
         :CURRENT_PAGE := :APP_PAGE_ID;
         RETURN :LAST_PAGE;
      END;

v

Parent topic: Understanding Application Computations

### 15.6.2 About Application Computations that Execute On New Instance

Use the On New Instance Computation Point to retrieve information once within a user's session.

Typically an application computation runs at the same point across multiple pages in an application. The exception is computations having a Computation Point of On New Instance. These types of computations are useful when you only need to retrieve information once within a user's session. For example, if the application items do not depend on the logged in user, you can initialize them using the Computation Point On New Instance. To look up information that depends on the user, you can also use After Authentication.

If you configure applications to share the same session by setting the same cookie name in the authentication scheme, On New Instance and After Login, the application processes fire whenever Oracle APEX first processes a request for the application (that is, On New Instance), or processes a request of an authenticated user for the application (that is, After Authentication).

Parent topic: Understanding Application Computations

### 15.6.3 Creating an Application Computation

Create an application computation from Shared Compoents.

To create an application computation:

1. Navigate to the Shared Components page:
   1. On the Workspace home page, click App Builder.
   2. Select an application.
   3. On the Application home page, click Shared Components.

      The Shared Components page appears.

2. Under Application Logic, select Application Computations.
3. Click Create.
4. Edit the following attributes:
   1. Item, Sequence - Specify the sequence for this component. The sequence determines the order of evaluation.
   2. Item, Computation Item - Select the item this computation affects.
   3. Frequency, Computation Point - Select a process point at which this computation should be performed. Selecting After Submit causes the computation to be performed only after the page is displayed and then submitted.
   4. Computation, Computation Type - Select the manner in which this computation is performed.
   5. Computation, Computation - Enter the computation logic that corresponds to the computation type. See field-level Help for examples.
   6. Computation, Computation Error Message - Enter the error message that displays if the computation fails.
   7. Authorization, Authorization Scheme (optional) - Select an authorization scheme which must evaluate to True in order for this computation to execute.
   8. Conditions, Condition Type (optional) - Select a condition type that must be met in order for this computation to execute.
   9. Configuration, Build Option (optional) - Select a build option for this component.
   10. Advanced, Static ID - Enter a unique Static ID to identify this component in API calls or refer to it in application export files. If you change the Static ID, dependent components will retain their references, but any existing API calls using the old ID must be updated manually.
   11. Comments, Comments (optional) - Enter any comments.
5. Click Create Computation.

See Also:

Using Build Options to Control Configuration

Parent topic: Understanding Application Computations

### 15.6.4 Copying or Subscribing to Application Computations

Copy application computations from the current application or from another application. When copying an application computation from another app, you can also subscribe to it.

Tip:

Subscriptions enable developers to reuse shared components across several applications in a workspace. To learn more about subscriptions, see Using Shared Component Subscriptions.

Note:

When copying an application computation from another app, shared component dependencies are automatically resolved. To learn more, see About the Logic Resolving Dependencies.

To copy or subscribe to an application computation:

1. Navigate to the application computations page.
   1. Navigate to the Workspace home page.
   2. Click the App Builder icon.
   3. Select an application.
   4. On the Application home page, click Shared Components.
   5. Under Application Logic, click Application Computations.

      The Application Computations page appears. Note that the report includes the following columns: Subscribed From, Subscription Status, and Subscribers.

2. To copy an application computation within the current application:
   1. Search for the application computation and click Copy in the Copy column.

      The Copy Application Computation Wizard appears.

   2. New Computation Item - Select an application-level or a page-level item.
   3. Click Copy Application Computation.
3. To copy an application computation from another application:
   1. From the Tasks region, click Copy from another app.

      The Copy Application Computation Wizard appears.

   2. Application - Select the application from which you want to copy.
   3. Copy Application Computation - Select the application computation to copy.
   4. Subscribe - Set this flag to On to subscribe to the application computation.
   5. Click Copy Application Computation.

Parent topic: Understanding Application Computations

### 15.6.5 Subscribing to an Application Computation

Subscribe to an application computation on the Application Computations, Create / Edit page.

Subscriptions enable developers to reuse shared components across several applications in a workspace. To learn more about shared component subscriptions, see Using Shared Component Subscriptions.

Tip:

You can also subscribe to a search configuration by copying it and then subscribing. See Copying or Subscribing to Application Computations.

To subscribe to an application computation:

1. Navigate to the Application Computations page:
   1. On the Workspace home page, click App Builder.
   2. Select an application.
   3. On the Application home page, click Shared Components.

      The Shared Components page appears.

   4. Under Application Logic, click Application Computations.

      The Application Computations page appears. Note that the report includes the following columns: Subscribed From, Subscription Status, and Subscribers.

2. Select an application computation.
   The Application Items, Create / Edit page appears.
3. To subscribe to an application computation:
   1. Find the Subscription region.
   2. Subscription, Subscribe From - Select a master application computation to subscribe to and click Apply Changes.

      The subscribed component is automatically refreshed from the selected master.

4. To refresh a subscribed application computation:
   1. Find the Subscription region.
   2. Subscription, Refresh Application Computation - If the application computation is already subscribed, click Refresh Application Computation.
5. To unsubscribe from a subscribed application computation:
   1. Find the Subscription region.
   2. Subscription, Unsubscribe - Click Unsubscribe.

Parent topic: Understanding Application Computations

### 15.6.6 Accessing the Application Computation History Report

Once you create an application computation, you can view the Application Computation History report. The Application Computation History report displays a history of recently changed application computations by date.

To access the Application Computation History report:

1. Navigate to the Shared Components page:
   1. On the Workspace home page, click App Builder.
   2. Select an application.
   3. On the Application home page, click Shared Components.

      The Shared Components page appears.

2. Under Application Logic, select Application Computations.
3. Select the History at the top of the page.
4. You can customize the appearance the page using the Search bar at the top of the page. Available controls include:
   - Select columns to search - Resembles a magnifying glass. Click this icon to narrow your search. To search all columns, select All Columns.
   - Text area - Enter case insensitive search criteria (wildcard characters are implied) and click Go.
   - Go button - Executes a search or applies a filter.
   - Actions menu - Use the Actions menu to customize the report view.

See Also:

About the Actions Menu

Parent topic: Understanding Application Computations