title: Adobe DC - Save As using JavaScript
body: <p>This is my first attempt at using Javascript...</p>
  
  <p>I am attempting to create a Save As button on a form that will:</p>
  
  <blockquote>
    <ul>
    <li>Create a file name based on fields;</li>
    <li>Save to a specific folder (And if it doesn't exist then create
    folder);</li>
    <li>Bring up the "Save As" box for confirmation (as opposed to a silent
    save);</li>
    <li>Bring up a warning IF Adobe is going to save over an existing pdf
    (aka has the exact same name);</li>
    <li>Close Adobe after all of the above is executed.</li>
    </ul>
  </blockquote>
  
  <p>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.</p>
  
  <hr>
  
  <p>The code I have so far is:</p>
  
  <p><strong>Trusted Level Function</strong>
  <em>saved in a Notepad.js file under the Adobe / Javascript folder</em></p>
  
  <pre><code>mySaveAs = app.trustPropagatorFunction(function(doc,path) {
  app.beginPriv();
  doc.saveAs(path);
  app.endPriv();
  })
  
  
  myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path) {
  // Privileged and/or non-privileged code above
  app.beginPriv();
  mySaveAs(doc,path);
  app.endPriv();
  // Privileged and/or non-privileged code below
  });
  </code></pre>
  
  <p><strong>PDF Button</strong>
  <em>Code under button that is executed on Mouse up click</em></p>
  
  <pre><code>// 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() ;
  </code></pre>