adding confirmation before submit form in Apex

Viewed 4922

I am trying to add a confirmation box before submitting a form in apex. Any ideas of how i can achieve that?

 <script type="text/javascript">
   response = response2();

  function response2(){
  apex.confirm("Are you sure  you want to submit?)}
</script>
3 Answers

This could be achieved without any custom JavaScript code...

1) Set the button which submits the form to action "Defined by Dynamic Action" and give the button a static id

button definition

2) Define a new Dynamic Action which executes when this Button is pressed

3) This DA then have to native actions:

- Confirm

- Submit (Request / Button Name: The static id of your button)

DA definition

Suppose that you're submitting a form by pushing the P1_BTN_SUBMIT button.

Set its action to Redirect to URL whose contents is

javascript:if(confirm('Are you sure??')){doSubmit('P1_BTN_SUBMIT');}

One option is to define the behavior of the submit button to "Redirect to URL". Then in the Target URL place the following javascript code;

javascript:apex.confirm('Are you sure?','REQUEST');

For example, this is the default behavior of the delete button:

enter image description here

Related