How to Block Multiple Submissions of the Same Document from the Web

Technote (FAQ)


Question

A form that is used on the web must have a Submit button if the document is to be saved in a Domino database. If the database has a $$QuerySaveAgent which does some complex processing, the agent may take some time to run. The user submitting the document may not realize that a process is running and may select the Submit button multiple times because nothing appeared to happen the first time they selected the button.

A user might also submit the same document multiple time by clicking on the Back button after submitting the document the first time and then clicking the submit button a second time.

Selecting the Submit button multiple times generates multiple, identical HTTP requests to Domino which causes multiple, identical documents to be created. It has also been reported that if the Submit button is double-clicked quickly instead of single clicked, causing the document to be submitted twice, once as a save conflict.


Answer

To prevent multiple, identical documents from being created, you can trap the user's click of the Submit button, check to see if the document has already been submitted, and only "submit" the request one time. This can be done on the client side through JavaScript.


To do this, follow these steps to change the design of the form.

1. Add a $$HTMLHead field to the form. In the field formula, enter the following code:

      "<script language=\"JavaScript\">
      var isSubmitted = \"NO\";
      function checkSubmitted() {
      if (isSubmitted ==\"NO\") {
      isSubmitted = \"YES\";
      document._submitForm.submit();}
      }
      </script>"
    First, the <script language=""> tag tells the browser that what follows is JavaScript. Next, the global variable isSubmitted is set initially to "NO". Then the function checkSubmitted is defined by checking the value of the variable isSubmitted. If the value is "YES" it does nothing and does not submit the document. If the value is "NO", then first isSubmitted is set to "YES" and next the document is submitted.
    Note: The line document._submitForm.submit() may have to be altered to reflect the correct name of the HTML form that is being filled out. If the HTML form name is "FORM", the syntax would be:
      document._FORM.submit();

2. Add the following as Pass-Thru HTML:
      <input type="Button" value="Submit" onClick="checkSubmitted()">
    This puts a "Submit" button on the form which calls the checkSubmitted function. This function actually submits the document only one time. Be sure to remove the old Submit button from the design of the form to prevent confusion.

A second workaround that would prevent users from clicking the Back button and submitting the form additional time would be to use a META tag. With the META tag you can set the page to expire on a date that has already passed, and use the Pragma parameter to tell the browser not to cache the file. This will prevent the user from hitting the Back button on the browser and resubmitting the page multiple times. To do this place the following code into the $$HTMLHead field:

    "<META HTTP-EQUIV=\"expires\" content=\"Wednesday, 27-Dec-95 05:29:10 GMT\">
    <META HTTP-EQUIV=\"Pragma\"CONTENT=\"no_cache\">"

Supporting Information:



Related Documents:


    Cross Reference information
    Segment Product Component Platform Version Edition
    Messaging Applications Lotus End of Support Products Lotus Domino Designer

    Historical Number

    162614

Rate this page:

(0 users)Average rating

Document information


More support for:

Lotus End of Support Products
Lotus Domino Server

Software version:

4.6, 5.0, 6.0, 6.5

Operating system(s):

AIX, Linux, Solaris, Windows, i5/OS, z/OS

Reference #:

1089865

Modified date:

2003-07-09

Translate my page

Machine Translation

Content navigation