Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript issue with submitForm

Explorer ,
Apr 15, 2018 Apr 15, 2018

My form has a button with a javascript associated to the Mouse Up event.

The script code follows:

if (FormOk()==true) {

    //Confirmation request

    var nButton = app.alert({

      cMsg: "Do you want to submit this application form?",

      cTitle: "Submit form", nIcon: 2, nType: 2});

    if ( nButton == 4 ) {

        //Form collection email address

        cToAddr = "mailbox@example.com";

        // Set the subject and body text for the email message

        var cSubLine = "Application for Employment";

        // Set the subject and body text for the email message

        var cBody = "Instructions to handle this application form:\n" +

          "1. Double-click the attachment\n" +

          "2. Select a response file";

        //Build email URI

        var cURI = encodeURI("mailto:" + cToAddr + "?" +

          "subject="+ cSubLine + "&body=" + cBody);

        //Exception handling

        try {

            //Submit form by email

            this.submitForm({cURL: cURI, cSubmitAs: "PDF"});

            app.alert({

              cMsg: "Your application has been submitted",

              cTitle: "Submit form", nIcon: 3});

        } catch(e) {

            //Display error info

            app.alert({

              cMsg: "Application NOT submitted\n\n" +

                e.name + " on line: " + e.lineNumber +

                "\n\n" + cURI});

        }

    } else {

          app.alert({

            cMsg: "Your application WAS NOT submitted",

            cTitle: "Submit form", nIcon: 3});

    }

}

This should work as per the documentation but it is not and it is driving me crazy.

The issue happens using my Outlook mail client and also using Gmail webmail client.

I would appreciate any ideas about how to solve this issue.

Thanks in advance!

TOPICS
PDF forms
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2018 Apr 15, 2018

What issue? What happens when you click it? Is there an error message of some kind?

Also, did you define a function called FormOk that return a boolean?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2018 Apr 15, 2018
LATEST

Sorry I should have explained that the FormOk function performs several data validation and returns false if there is any error, true otherwise.

What happens depends on several situations:

If using Outlook mail client it silently fails and the "Your application has been submitted" alert is displayed.

If using Gmail webmail client then:

  1. The following dialog displays:

    Clicking the Details button displays:

  2. Clicking Yes displays several progress messages:
    Preparing to Send Message ...
    Connecting ...Creating Draft ...
    and the following dialog:
  3. Clicking Yes raises an exception:
    Exception in line 26 of function top_level, script Field:Mouse Up

    RaiseError: Error while creating message.
    Doc.submitForm:26:Field Submit:Mouse Up
    ===> Error while creating message.

    So I added the try{}..catch{} to handle the exception and got the following dialog:

     which shows that the mailto URI is Ok

Now it is fully documented.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines