4 Replies Latest reply on Aug 9, 2011 5:10 PM by George_Johnson

    Remove submit button after document has been signed

    ctasqa

      I have a PDF document with two signature fields and a submit button. We generate an XFDF file which fills in the fields on the PDF, which our users then access, sign the two fields, and click a submit button which submits it back to us as a PDF with the values filled in, where we archive it for later viewing. I've been trying to add a script to the submit button so that once the user submits it, the button is removed (this.removeField("SUBMIT BUTTON");) before the form submits so that it won't be in the archived copy of the form (to prevent multiple submissions). When I skip the signatures and just immediately click the submit button, this works fine, but if I actually sign the document first, the button isn't removed. I suspect that signing the document may somehow be locking it and preventing the button from being removed; if so, is there another way to accomplish this? I read about certification signatures versus approval signatures in the docs, which stated that certification signatures can prevent other parts of the document from changing, but I don't see anywhere in Acrobat that controls whether a signature field is one or the other.

        • 1. Re: Remove submit button after document has been signed
          gkaiseril MVP & Adobe Community Professional

          This can be tricky since you are trying to delete an in use object.

           

          Take a minute to think what could happen if what is modifying the form and has more work to do suddenly disappears.. It might be like writing a note on a piece of paper and have paper disappear before you sign the note.

           

          You can use JavaScirpt to hide and make the field read only.  Out of sight and non-click able.

           

          Have you looked at what the signing does to the various form fields?

          • 2. Re: Remove submit button after document has been signed
            George_Johnson MVP & Adobe Community Professional

            The problem with this is removing the button after the signature is applied will show that the document has changed after the signature was applied when the signature is verified. But that may be OK.

             

            Another problem is of you remove or hide the button after it's clicked and an error occurs, it will remain gone or hidden so the user will be unable to click it again if the condition that caused the error is corrected.

             

            Regarding signatures locking the document, this is an option that the user can select if the signature field that's being signed is the last blank signature in the document.

             

            I can imagine a scripting solution that prevents the submit taking place if it's already been submitted. You could set up a variable that keeps track of this, but you'd then have to use the submitForm JavaScript method, as opposed to using a "Submit a form" action for the button.

            • 3. Re: Remove submit button after document has been signed
              ctasqa Level 1

              GKaiseril: I had the same concerns you did about removing the submit button while it was submitting, but when I submitted it before signing anything and the button was removed, it did submit fine.

               

              George: The security may already be compromised by a different script that is working; this isn't a huge deal, but it would be nice if it would verify. The two signatures are for a borrower and optional co-borrower. We've currently got it set up so that once the primary signature is signed, a script checks whether a co-borrower exists, and if not, removes the second signature field (which works fine at the moment). It's set up to run on mouse down, so I'm not sure if it would run before or after the signature actually completes. Actually, this brings me back to a question I had when I first started working on this that I've just been working around: is it possible to create a script that runs when the document first opens? I searched for this for a while and never found any reference to it. If so, I could avoid the need to have a script on the signature field. As far as setting a variable to keep track of it, it seems to me like once we set the variable, the submission could still fail, but the variable would still be set and prevent submitting again. However, I might be able to check the documentFileName. When we archive the submitted PDF, we assign it an automatically generated name like 00000000467.pdf, so I can have the submit button check whether the name matches the original name (which we already store in a hidden field). In fact, if it's possible for the script to run when the document first opens, the submit button can be disabled (or hidden/readonly, if that would work better with document security) from the very beginning instead of disappearing when they try to click on it.

              • 4. Re: Remove submit button after document has been signed
                George_Johnson MVP & Adobe Community Professional

                Yes, you can include code in a document-level JavaScript outside of a function definition and it will execute when the document first opens. You can also place code in the initial page's Page Open event and it will execute when the document opens.

                 

                Regarding the variable, if you use a try/catch block and only set the variable if no error is caught, it should help.