3 Replies Latest reply on Mar 12, 2015 4:15 PM by cxvmcx

    Using javascript to save a pdf to a different directory and generating a new filename based on form fields in the document.

    cxvmcx Level 1

      I have built the following script in an attempt to create a submit button that will automatically save the document in a different directory on my computer. It will also use the form field data "customer" and "date" to generate the filename. I printed out the variable myPath and it looks like it printed the correct string. I keep getting the following error:


      TypeError: redeclaration of const path


      any help would be much appreciated.






      var customer = this.getField("Customer").value;

      var date = this.getField("Date").value;

      var path = "C:/Users/awilliams/My Documents/Test/"


        var reg = date.match(/(\d+)\/(\d+)\/(\d+)/);



      var myPath= "C:/Users/awilliams/My Documents/Test/" + customer + "_" + reg[1] + "." + reg[2] + "." +

      reg[3] + ".pdf";