2 Replies Latest reply on Mar 9, 2010 5:06 AM by jeanmed

    Saving a Form

    WeDoBoring

      I think I need to to use folder level scripting, but an unsure how to do this.

       

      I have a form that is sent out to about 15 Foremens laptops.  They will be filling this out daily and returning them to the office via email.  They need to also be able to save them locally.  The process will be as follows;

       

      They open the form and fill it in, then select a button.

       

      When selecting the button it will automatically extract three fields from the file (Job, Location, Foreman) and compile a filename and email.

       

      The file will then will be saved to a specific location of C:\data\Job - Location - Foreman.pdf

       

      If the file exists I want to overwrite it.

       

      After the file is saved I want to email it to the office.

       

      I have the email part figured out, but stuck on the saving part.  I do not want them to have to input any of the filename or directory path.  It is not a big deal it they have to click ok on the save of overwrite, if needed.

       

      /Create Email message

      var cMyMsg = "Job - " + this.getField("Job#.0").value;
      cMyMsg += " - " + this.getField("City/State").value;
      cMyMsg += " - " + this.getField("Foreman").value;

       

      /Create File name

      var cMyFile = "Job - " + this.getField("Job#.0").value;
      cMyFile += " - " + this.getField("City/State").value;
      cMyFile += " - " + this.getField("Foreman").value;
      cMyFile += ".pdf";

       

      /Enter the save as prompt

       

       

      /Mail pdf to office

      this.mailDoc({
      cTo: "office@domain.com",
      cSubject: cMyMsg,
      cMsg: cMyMsg
      } );

       

      Any help or examples would be appriciated.

        • 1. Re: Saving a Form
          WeDoBoring Level 1

          Here is what I have done and it seems to work in my case.

           

          ***************************************************************************
          I created a file named filename.js in the javascripts directory under Adobe and added the following code
          ***************************************************************************

          // should allow priviledged calls to saveAs method
          TrustFNsaveAs = app.trustPropagatorFunction(function(docvalue,saveFilename)

          {
          app.beginPriv();
          docvalue.saveAs({cPath: saveFilename});
          app.endPriv();
          })
          FNsaveAs = app.trustedFunction(function(docvalue,saveFilename)
          {

          // privileged and/or non-privileged code above
          app.beginPriv();
          TrustFNsaveAs(docvalue,saveFilename);
          app.endPriv();
          });

          ***************************************************************************
          I added the following to a button click on the Form
          ***************************************************************************

          // Create Subject and Message for Email
          var cMessage = "Job - " + this.getField("Job#.0").value;
          cMessage += " - " + this.getField("JobCity.0").value;
          cMessage += " - " + this.getField("JobState.0").value;
          cMessage += " - " + this.getField("Foreman").value;

           

          //Check for invalid characters in Filename
          var cFilename = cMessage.replace(/[?:\\/|<>"*,]/,"");

           

          // Compile Path and Filename
          var cFile = ("/p/data/" + cFilename + ".pdf")

           

          //Run Save Function
          {
          FNsaveAs(this, cFile);
          }

           

          //Email File
          this.mailDoc({
          cTo: "office@domain.com",
          cSubject: cMessage,
          cMsg: cMessage
          } );

           

           

          ***************************************************************************
          You can name the following anything, I changed them from what I used to more generic names

           

          FNsaveAs
          cMessage
          CFilename
          cFile

          • 2. Re: Saving a Form
            jeanmed Level 1

            Dear,

             

            Can we set the xml file name to.

             

            Thanks