4 Replies Latest reply on Feb 12, 2014 5:42 PM by North by North-East

    Javascript issues for a PDF form

    North by North-East

      Hi everyone,

       

      I hope someone can help me, i posted a few days ago but managed to find a script somewhere online to do half of what i needed.

       

       

      //-------------------------------------------------------------

      //-----------------Do not edit the XML tags--------------------

      //-------------------------------------------------------------

       

      //<Document-Level>

      //<ACRO_source>Numbering</ACRO_source>

      //<ACRO_script>

      /*********** belongs to: Document-Level:Numbering ***********/

      var f = this.getField("Tracking Number");

      if (f.value=="") f.value = "0001001";

      else f.value = util.printf("%04d", (Number(f.value)+1));

      //</ACRO_script>

      //</Document-Level>

       

       

       

      Problem I have now is that it will only update the Tracking Number field (field is after the A) when i save the original document, not when i save as a copy. This will be accessed by multiple people and what i want is the number to update each time it is saved as a copy (so there will never be two documents with the same number, VERY IMPORTANT). This document is essentially a digital carbon copy form then sales reps use.

       

      I was also hoping there can be a script written to update the file name with the tracking number, so it rules out human error - the script will Save a copy, in a designated folder, with a set file name (Booking_form_#customername_#trackingnumber.pdf)

       

      Am i just hoping for too much?

       

       

       

      Screen Shot 2014-02-13 at 10.53.44 AM.png

        • 1. Re: Javascript issues for a PDF form
          George_Johnson MVP & Adobe Community Professional

          As Gilad mentioned in that other thread, the problem with doing it this way when multiple people can have the document opened at the same time is there's now way to guarantee a unique number. You could set it up so that the number is requested from a web server which does the job of coordinating things, but this wouldn't work with Adobe Reader on mobile devices. You might want to move to a different type of code like a timestamp combined with some sort of user identifier. For example: GWJ_20140212163359042.

          • 2. Re: Javascript issues for a PDF form
            North by North-East Level 1

            Oh yeah.... Well this PDF will be located on our server, is that what you are referring to?

             

            A timestamp wouldn't quite work as it does need to be sequential numbering as these will be correlated with our accounts departments.

             

            I just would of thought with carbon copy books being used so much in business, why there is not a easy digital way to do the same thing. It's crazy. I can't be the first person wanting a digital carbon copy style form.

            • 3. Re: Javascript issues for a PDF form
              George_Johnson MVP & Adobe Community Professional

              Regarding the server, I was referring to setting up a web server with a script that the form could sumit a request to whenever it needed an new number, not a file server where the PDF resides. The server would check a database and reserve a new number and return it to the form for use. This would require some server programming, but it's the best way to do it. The problem is it won't work with Adobe Reader on mobile devices.

               

              This type of thing is indeed a common thing to want, but it's hard to do from within the document itself since there's no way of knowing what other users are doing. With a physical book or invoice pad, it's not possible to use a number more than once like it is with a multi-user e-form that's not controlled by a server.

              • 4. Re: Javascript issues for a PDF form
                North by North-East Level 1

                Have no idea about a web server....

                 

                What if, I had a PDF from for each person, and just give them a different prefix to identify which rep is. Instead of using 'A'. Would the sequetial numbering work then, if the original is save locally?

                 

                My other thought it as you mentioned the mobile device, they would be using an iPad to do this too..... will the Javascript copy across onto that platform?