Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Try67, that seems like a pretty damn option - considering the alternatives. How does one go about adding that feature?
Copy link to clipboard
Copied
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
}
Copy link to clipboard
Copied
And where do I put this? Is this just a script I can add to a button?
Copy link to clipboard
Copied
Yes, exactly.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more