0 Replies Latest reply on Oct 9, 2015 4:18 PM by amyr28466165

    Transfer data from one form to another

    amyr28466165 Level 1

      This script works for copying data from one file to all other files within the portfolio that have the same form fields.  My question is what do I need to change to make this work for a pdf file attachment? I have a pdf file that consists of 65 pages.  Certain pages from this pdf file will need to be uploaded but not the entire 65 page pdf document.  So I have made a copy of those few pages and saved them as one combined pdf attachment.  I do not want users to have to re-type in all the form field information to upload these pages.


      This process works great for portfolios.  I need the same concept for pdf attachments...


         // the list of files to process:

         var lPortfolioFiles = [ "Annual 504 Parent Packet (English).pdf", "Form 7.pdf", "Annual 504 Review (English).pdf", "Form 13.pdf", "Form 13 - BIP.pdf", "Additional Notes Page.pdf", "Form 15.pdf", "Form 17.pdf", "Form 18.pdf", "STAAR-A (English).pdf" ];


      function CopyDataToFile(source, dest) {

          // iterate over all form fields in the destination form and copy from

          // the field with the same name from the source (if available)

          for (var i=0; i<dest.numFields; i++) {

              var fieldName = dest.getNthFieldName(i);

              var f1 = source.getField(fieldName);

              if (f1 != null) {

                  dest.getField(fieldName).value = f1.value;

      console.println("Field name: " + fieldName + "\nData = " + f1.value);





      function CopyData(doc)


        // what is our file name?

        var myFileName = doc.path;

        // get the portfolio part of the path

        var re = /(\|.*\|)(U:(\uFEFF|\uFFFE)<0>)(.*)/;

        var res = myFileName.match(re);


        // process all files in the list

        for (var i in lPortfolioFiles) {

        var fileName = res[1] + res[2] + lPortfolioFiles[i];

        var d2 = app.openDoc(fileName);

        CopyDataToFile(doc, d2);