I am trying to save a form by inserting JavaScript into a button in an acrobat form. The field names I have put into the formare AccountName and AccountNumber; the form should be saving itself as; AccountNumber-AccountName-Date.pdf. Here is the JS I have so far; and it only seems to work sometimes. Can anyone help me figure out what is wrong with my archive button??? It either saves the form as AccountName-date.pdf or AccountNumber-date.pdf; I can't get it to read all three fields.
//Mouse up action of Save button, only works if there is an associated .js file in Adobe's Javascript folder on the user's hard drive
//This statement gets the value that is entered into a field
var a = this.getField("AccountNumber");
//This statement assigns that value as a variable to be used later
var av = a.value;
var b = this.getField("AccountName");
var bv = b.value;
//This statement pulls today's date to be used for naming the file
var cv = util.printd ("ddmmmyy", new Date());
var z = this.getField("dash");
var zx = z.value;
//This statement calls the function in the .js file and uses the stored variables to name the .pdf
myTrustedSpecialTaskFunc(this, "/c/Save_Folder/" + av + zx + bv + zx + cv + ".pdf");
//This statement controls the what is written on the title bar of the pop-up
var dialogTitle = "** FORM SAVED TO C: DRIVE **";
//This statement creates the pop-up and the verbiage that is written in the pop-up
var reply = app.alert({ nIcon:3, cMsg: "\nThis form has been saved to Save_Folder on the C: drive.\n\nPress OK, then close the browser window.", cTitle: dialogTitle, nIcon: 3, nType: 0});
this.closeDoc(true);
var av = a.valueAsString;
And you probably don't need to store the dash character in a field. You could do this instead:
var zx = "-";
or
"/c/Save_Folder/" + av + "-" + bv + "-" + cv + ".pdf"
George