Skip to main content
December 15, 2017
Question

Interactive buttons running Javascript to save to specific file location not working

  • December 15, 2017
  • 1 reply
  • 759 views

Hi,

I have a PDF form with 2 buttons at the top that are set to run a Javascript. One of them saves the file to a specific server location under a certain file name. The other saves it in the same way and also sends an email with the form as an attachment.

In previous versions of this form, both buttons worked perfectly fine. I have changed a number of things now about the form itself but no changes were made to the buttons. However, the save function of the buttons no longer work (though the second button still generates an email fine).

I've run through every line of Javascript code and confirmed it's the same as the previous version, so I don't think it's the code. I feel like it's a setting on the doc itself, but as far as I can see, they're all the same as well. Any ideas what else (settings or anything else) might block the save function on the buttons from working?

Thanks in advance!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 15, 2017

Are there any error messages? Can you post the code you're using?

On 15 December 2017 at 04:51, hollys45933388 <forums_noreply@adobe.com>

December 15, 2017

There are no error messages. It doesn't do anything at all. This is the code I am using for the save button.

function myDateString(){

return util.printd("mmddyyyy", new Date()); }

var mySaveAs = app.trustedFunction( 

  function(oDoc, cPath, cFlName) { 

  // Ensure path has trailing "/" 

  cPath = cPath.replace(/([^/])$/, "$1/"); 

  try { 

  app.beginPriv(); 

  oDoc.saveAs(cPath + cFlName); 

  app.endPriv(); 

  } catch (e) { 

  app.alert("Error During Save - " + e); 

  } 

  } 

); 

// determine the directory path for the current document

var directory = "/s/Server/completed forms"

if (typeof(mySaveAs) == "function") {

  mySaveAs(this, directory, this.getField("LegalName").value + "_" + this.getField("Interviewer").value + "_"+ myDateString() + ".pdf");

} else {

  app.alert("Missing Save Function. Please contact administrator for help ");

}

Another thing, I have this doc in a folder on a shared server, and that folder is locked for editing except by me. It's a different folder than the save path in the code (the template is in /s/Server/templates but the button is supposed to save the file to /s/Server/completed forms). Could that somehow be affecting it?

Thanks

Inspiring
December 15, 2017

All JavaScripts that are run in Acrobat/Reader need to be within the PDF or in one of 2 very specific folders on the user's system. They cannot be anywhere else.