Call folder level javascript outside of the folder?

Avatar

18-01-2009

Hi, im kinda new to LiveCyle 8. And ive run into a difficulty. I have a form that requests data from the user, and i want it to be able to, when it submits via email, to have the file name as [namefield]_[datefield].pdf from the contents of the form. Ive gotten the email button and all that stuff working, im just having problems naming it. Ive found a work around to autosave the file just before emailing it, with a folder level javascript. But i will not be able to use this javascript outside of my own computer and i need to be able to put it onto a website. I tried creating a script object and tried putting the JS code in there but it didnt work. Is there anyway to link the JS from the pdf file, or any other workaround for this?



Here is the code for the .js file in the acrobat/javascripts folder:



saveFunc = app.trustedFunction(function (path) {

app.beginPriv();

try {

event.target.saveAs(path);

} catch (err) {

console.println("Error: " + err);

}

app.endPriv();

});



Here is the code from the click event of my button:



var suggestedName = TextField1.rawValue.replace(" ", "_") + "_" + DateTimeField1.rawValue + ".pdf";

var cPathToSaveTo = "/c/program files/";

saveFunc( cPathToSaveTo + suggestedName );



When i tried the script object, named mySaveDoc i changed the button code to this:



var suggestedName = TextField1.rawValue.replace(" ", "_") + "_" + DateTimeField1.rawValue + ".pdf";

var cPathToSaveTo = "/c/program files/";

mySaveDoc.saveFunc( cPathToSaveTo + suggestedName );

Replies

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

19-01-2009

To be able to call folder level javascript you have to have the js file on the machine that is making the call. You cannot link to it through the web because of security concerns. So unless you distribute the file and have your users put the js file in the correct place this will not work.