23 Replies Latest reply on Jul 26, 2018 2:19 AM by try67

    Help with Save As using JavaScript

    sebastianb99835257 Level 1

      Hi All,


      This is my first attempt at using Javascript...


      I am attempting to create a Save As button on a form that will:

      • Create a file name based on fields;
      • Save to a specific folder (And if it doesn't exist then create folder);
      • Bring up the "Save As" box for confirmation (as opposed to a silent save);
      • Bring up a warning IF Adobe is going to save over an existing pdf (aka has the exact same name);
      • Close Adobe after all of the above is executed.


      So far I have been fairly successful. I have been able to do a silent save, saving to a specific location and saving the file name based on fields. I need help building the rest of the functionality into the code if possible.


      Thanks in advanced!

      ------------------------------------------------------------------------------------------ -------------------------------

      The code I have so far is:


      Trusted Level Function

      saved in Notepad under the Adobe / Javascript folder


      mySaveAs = app.trustPropagatorFunction(function(doc,path) {







      myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path) {

      // Privileged and/or non-privileged code above




      // Privileged and/or non-privileged code below



      PDF Button

      Code under button that is executed on Mouse up click


      // build file name

      var myFileName = getField("Work_Pack").value + " - " + getField("Form_Name").value + " - " + getField("Todays_Date").value + ".pdf";

      // add folder name

      myFileName = "/c/temp/Saved Forms/" + myFileName

      myTrustedSpecialTaskFunc(this, myFileName);


      this.closeDoc() ;


      ------------------------------------------------------------------------------------------ -------------------------------