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

Is there a javascript that will enable me to save the document as the auto-generated field?

New Here ,
Jun 19, 2018 Jun 19, 2018

I have a "submit" button that, when pressed by the user, it will bring up a save screen and then brings up an email window that attaches the document and sends it to an email address I selected. I want to add some script that, when the save window is brought up, the name in the document name window matches the invoice number that is auto-generated with the document. If this isn't possible, I would want the window to be totally blank so the user has to type in a number. Thanks!

TOPICS
PDF forms
1.3K
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 ,
Jun 19, 2018 Jun 19, 2018

Neither of these things is possible. What you can do, though, is prompt the user to use a specific file name when saving the file, and even prevent the file from being submitted if it doesn't have that file name.

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
New Here ,
Jul 22, 2018 Jul 22, 2018

Try67, that seems like a pretty damn option - considering the alternatives. How does one go about adding that feature?

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 ,
Jul 22, 2018 Jul 22, 2018

You can use something like this:

var invoiceNumber = this.getField("InvoiceNumber").valueAsString;

var desiredName = invoiceNumber + ".pdf";

if (this.documentFileName!=desiredName) {

    app.response("You must save the file using this name before submitting it:", "", desiredName);

    app.execMenuItem("SaveAs");

}

if (this.documentFileName==desiredName) {

    this.mailDoc({cTo: "me@server.com", cSubject: "Email subject", cMsg: "Email message body"}); // Replace with actual email address, subject line and body

}

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
New Here ,
Jul 22, 2018 Jul 22, 2018

And where do I put this? Is this just a script I can add to a button?

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 ,
Jul 22, 2018 Jul 22, 2018

Yes, exactly.

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
New Here ,
Jul 22, 2018 Jul 22, 2018

Cool, the script created the pop-up warning (showing the suggested invoice number) as planned, but I don't see how it prevents a user from submitting the form if they don't use the number. Once you click okay, and get to the "Save As" window, it just defaults to your file name and anything can be entered ... or worse ... the user just leaves it as the default file name and overwrites the file.

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 ,
Jul 22, 2018 Jul 22, 2018
LATEST

Unless they save the file under the desired name it will never reach to the line of code that submits the form by email.

Of course, they can always manually create an email and send it to you. That can't be avoided. But if you specify a specific subject line, for example, you could reject or ignore any emails that don't have that line out of hand, so their file will not get processed.

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