Copy link to clipboard
Copied
i know absolutely nothing about java so be patient with me.
i have created a pdf work order that i would like to have generate a new work order number each time i open it.
i dont know where to start from . i have found some script examples but i dont know how to implement or place it to have the result show where i want it on the document.
any help would be greatly appreciated
JavaScript is case-sensitive.
Copy link to clipboard
Copied
You can do it using a text field and a script.
What code did you find?
Copy link to clipboard
Copied
this is the script i found, but having absolutely no knowledge of any kind of computer programming i dont even know where to input or how to do it.
trying to learn and do
thanks for the help and understanding
var f = this.getField("Tracking Number");
if (f.value=="") f.value = "0001";
else f.value = util.printf("%04d", (Number(f.value)+1));
Copy link to clipboard
Copied
That code should work. You just need to create a text field called "Tracking Number" and then paste that code into the editor window under Tools - JavaScript - Document JavaScripts, under a new item (call it "scripts" for example). Make sure to overwrite all pre-existing code in that window, though.
Copy link to clipboard
Copied
i have entered as you suggested but i am not getting any results.i have included images ,
Copy link to clipboard
Copied
JavaScript is case-sensitive.
Copy link to clipboard
Copied
lol. guilty of overlooking the simple because i convinced myself the answer was complex.
thank you for your help
Copy link to clipboard
Copied
Hi, I have a question, I have entered the code and it works. However, when you click on the number it rolls. Even after saving the form the number rolls as well. How do I keep the form number from rolling when the number is clicked on and after it is saved?
Copy link to clipboard
Copied
The trick to solving a programming issue is to think through how you want it to work, write down the exact steps that are need to accomplish it, then ask us for suggestions on how to implement it.
The code presented here is designed to run each time the form is opened. If you want something different, the tell us how you want it to work.
Copy link to clipboard
Copied
Can you tell me how to edit this script to generate the new number upon printing? Currently it changes on saving and opening.
var f = this.getField("Tracking Number");if (f.value=="") f.value = "0001";else f.value = util.printf("%04d", (Number(f.value)+1));
Thank you!
Copy link to clipboard
Copied
Move the code to the Will Print event of the document, under Tools - JavaScript - Set Document Actions.
Copy link to clipboard
Copied
Perfect! Thank you for your prompt assistance.