OverView

This document talks about how to add a confirmation dialog alert in oracle apex using JavaScript.  We are going to add a confirmation dialog alert using apex.message.confirm() JavaScript method.

Technologies and Tools Used

The following technologies have been used to achieve the expected output.

Ø JavaScript

Use Case

In Oracle Apex, If the application requires confirmation from the user to perform some action. We can use this apex.message.confirm() JavaScript method to perform that particular action. For example, if the user clicks the delete button or checks/un-check the check box on the time, we can add this JavaScript method to display the “Are you Sure?” dialog box.

Syntax:

apex.message.confirm( “Are you sure?”, function( okPressed ) {

if( okPressed ) {   // do somethig if ok button pressed}

});

Example:

We are having the form region with the save button. when the user clicks the save button dialog alerts need to display with the alert message. When users click the “OK” below the form region reports need to enable. If the user cancels the alert report need not enable.

The below steps explains how to achieve this example.

Architecture

Step 1:

The form region needs to be created with the save button.

Step 2:

The item needs to be been created as “P8_VALUE” and an employee report needs to created with the server-side conditions.

Step 3:

The dynamic action needs to create for the save button with action as Execute JavaScript.

apex.message.confirm( “Are you only want to see the employee salary?”, function( okPressed ) {

if( okPressed ) {

apex.item(“P8_VALUE”).setValue(“Y”);

} else {

// this code will execute if cancel button pressed

apex.item(“P8_VALUE”).setValue(“N”);

}

apex.submit(“#SAVE”);

});

 

ScreenShot

Output:

We can achieve this by adding JavaScript in dynamic action. The screenshot added is the example.

Recommended Posts

Start typing and press Enter to search