4 Replies Latest reply on Dec 13, 2016 6:35 AM by egar040203

    Create a JavaScript

    egar040203

      Hello all -

      I am hoping someone could help me create javascript for a personal reimbursement for that I have created for my office.

       

      I would like for the employee id (six digit number) to auto populate in field B, when an employee enters their last name in field A. There is approx 50 or so employees in my office and I would like to capture all of them in these to fields.

       

      Thank you in advance for you help.

        • 1. Re: Create a JavaScript
          try67 MVP & Adobe Community Professional

          There are a couple of ways it can be done. You can hard code the employee numbers and names into a script and then use a simple lookup or if-condition, or you can do it using an embedded text file that contains all of that data, and then when you need to update the list you just replace the text file with the new version and it will automatically update the lookup table. The latter is more complex, of course, and requires a custom-made script, but is much easier to maintain in the longer run.

           

          For the former see this tutorial: https://acrobatusers.com/tutorials/change_another_field

           

          If you're interested in hiring someone to develop the latter for you, feel free to contact me privately via try6767 at gmail.com.

          • 2. Re: Create a JavaScript
            egar040203 Level 1

            I haven't done any scripts for a while now, but how would hard coding the employee numbers and names look like in a script?

            • 3. Re: Create a JavaScript
              try67 MVP & Adobe Community Professional

              The most simple way of doing it is with a series of statements like this (this code should be placed as the custom calculation script of the Employee ID field):

               

              var employeeName = this.getField("Employee Name").valueAsString;
              if (employeeName=="") event.value = "";
              else if (employeeName=="John Doe") event.value = "123456";
              else if (employeeName=="Jane Doe") event.value = "789000"; // etc.
              
              • 4. Re: Create a JavaScript
                egar040203 Level 1

                Thank you Try67. Worked beautifully.