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

SaveAs with part of filename from form

jcarmody
Registered: Dec 8 2008
Posts: 15

I'm having troble following the advise given in this thread: http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=16903

Basically, I want to do the same thing radzmar wanted to do. I'm almost there but my inexperience with the products are holding me back.

I have created a folder level config.js file that looks like this:

//DateTime function
function myDateString() {

return util.printd("yyyymmdd_HHMMss", new Date());

}

// SaveAs Function test
var mySaveDoc = app.trustedFunction(function(doc) {

app.beginPriv();
var myPath = "/drive/morepath/" + myDateString() + ".pdf";

// saveAs is the only privileged code that needs to be enclosed
// with beginPriv/endPriv
doc.saveAs(myPath);
app.endPriv();

});

I have a button on my form with the following in the on click event:

mySaveDoc(event.target);

Now I want to add the contents of the field titled "Employee_Name" to the end of the file name (after the date/time string).

I believe the whole field name is topmostSubform.Page1.Article.Employee_Name

I don't know how to change my config.js and where or how to pass the contents in the employee name field along.

Any help would be appreciated

Jcarmody

My Product Information:
LiveCycle Designer, Windows
jcarmody
Registered: Dec 8 2008
Posts: 15
I thought I'd add some more information to this post.

First off, the save as and my config.js works great! That is the good news. I just need to pass a value from the form to be part of my file name. I've now added the following to a mouse down event in my form:

name = resolveNode("topmostSubform.Page1.Article.Employee_Name").rawValue;
event.target.mySaveDoc(event.target);

In the java debug window I get the message:

name is not defined
13:Folder-Level:User:config.js

Do I need to add a reference to name in my config.js? What would be the format.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Try this script in the mouse up event (not mouse down) in your form.
Make shure the field does not contain characters like /\?!{}.
These ones cannot be used for file names and returning a RaiserError in the console.
**************************************************************
name = resolveNode("topmostSubform.Page1.Article.Employee_Name").rawValue;
event.target.mySaveDoc(event.target);
**************************************************************Then change the folder level script and close and reopen acrobat or reader.
Sometimes it still will be used the old script, then you should do a reboot of your machine.
**************************************************************
//DateTime Function
function myDateString()
{
return util.printd("yyyymmdd_HHMMss", new Date());
}
// SaveAs Function
var mySaveDoc = app.trustedFunction(function(doc)
{
app.beginPriv();
var myPath = "//drive/morepath/" + myDateString() + " " + name + ".pdf";
doc.saveAs(myPath);
app.endPriv();
}
);
**************************************************************

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

jcarmody
Registered: Dec 8 2008
Posts: 15
Still no joy.
I get this in the java debug window:
name is not defined
11:Folder-Level:User:config.js

How do you find out the whole path to the text field?
Is it correct that I don't have to set up name as a var in my folder level script?

Janet
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The code
name = resolveNode("....").rawValue;
defines a global variable "name" when you click your button, that will be used by the folder level script.

To get the whole path of your textfield, activate it in the design view and choose one action like "click" in the script editor.
The editor shows the whole path on the top of the script window.
**************************************************************
Form1.Page1.Textfield1::click - (JavaScript, client)
**************************************************************

Copy the part left from :: ! That's the whole path!

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

jcarmody
Registered: Dec 8 2008
Posts: 15
I'm still getting the Name is not defined message in the Java console window.

So something must be wrong with

name=resolveNode("topmostSubform.Page1.Article.Employee").rawValue;

I verified the path was OK and changed the field name from Employee_Name to Employee thinking that maybe the 2 part field name was a problem.

Is there any way to validate this command?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Is your form set to "dynamic" in the preferences?

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

jcarmody
Registered: Dec 8 2008
Posts: 15
I got it working. I changed my field name from name to empname thinking that maybe name is protected. Its probably not really it, but now everything is working.

Thank you so much.