These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Pull Field Data into File Name Upon Save

gte799f
Registered: Jul 25 2008
Posts: 3

I have seen a number of posts on this...but have not actually been able to get it to work (due to my very limited knowledge of javascript). I currently have a form that uses the script shown below to save and then email the form...however, what I want to achieve is the following:

1- User clicks "Save and Email File" button
2- Window's prompt appears with predetermined name (i.e. field1.pdf) during the save function (user can modify the name and select location).
3- Once the file saves it is then delivered to email client with email subject and body predetermined based on data in the form.

I have everything correct except for the predetermined name that appears during the save process.

Currently I have the following (and it does work for me):

---
app.execMenuItem("SaveAs");
var Comment = field1.rawValue;
if (field1.rawValue == null){ Comment = "New"} else {Comment = field1.rawValue};

event.target.submitForm({cURL:"mailto:myemail [at] anymail [dot] com?subject="+Comment+" Submission &body=Please review this submission: "+Comment+"",cSubmitAs:"PDF",cCharset:"utf-8"});
---

Based on some of the posts (thanks to Thom Parker, WindJack Solutions) it looks as if I should be using the following:

"app.response()" function and the "doc.saveAs()" function

Issue here is I dont not know enough about how to get this properly programmed in my "click" event to get them to work. Looking for something I can just cut and paste (with minor modification to field names, etc).

Can anyone help me?

P.S. Currently using Acrobat Pro 9.0 (LiveCycle Designer) with a target audience using Acrobat Reader 7.1 and up on both Window and Mac machines. File will have "Extended Features for Reader" enabled.

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You need to create a button field using the "Button" from the "Standard" library of LiveCycle Designer. You will then need to put your script into the "Mouse Up" option for the button.

To change the name of the file by JavaScript you can not use the "execMenuItem()" method but should use the "saveAs()" method:

var myDoc = event.target;
myDoc.saveAs();

Which will allow one to specifiy the path and file name.

Be aware there are a number of security restrications that may have to be delt with by a user of your form. This information is contained in the Acrobat JS API Reference.

George Kaiser

gte799f
Registered: Jul 25 2008
Posts: 3
Dear gkaiseril,

Thanks for the note. It didnt quite work for me. Below is a copy of the script...where am I wrong?...button just doesnt work (and rights have been enabled)....when I click it...it just sits there.

Let me know.

gte799f

---


form1.#subform[0].Button1::mouseUp - (JavaScript, client)

var Comment = Field1.rawValue;
var Comment2 = Field2.rawValue;

var myDoc = event.target;
myDoc.saveAs("+Comment+");

if (Field1.rawValue == null){ Comment = "New"} else {Comment = Field1.rawValue};

event.target.submitForm({cURL:"mailto:email [at] anyone [dot] com?subject="+Comment+" &body= "+Comment2+"",cSubmitAs:"PDF",cCharset:"utf-8"});