Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you Try67. Worked beautifully.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now