• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

sequential number

Community Beginner ,
Dec 22, 2018 Dec 22, 2018

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

TOPICS
Acrobat SDK and JavaScript

Views

830

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 24, 2018 Dec 24, 2018

JavaScript is case-sensitive.

Votes

Translate

Translate
Community Expert ,
Dec 22, 2018 Dec 22, 2018

Copy link to clipboard

Copied

You can do it using a text field and a script.

What code did you find?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 22, 2018 Dec 22, 2018

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));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 23, 2018 Dec 23, 2018

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 23, 2018 Dec 23, 2018

Copy link to clipboard

Copied

i have entered as you suggested but i am not getting any results.i have included images ,

script.PNGfield.PNGerror.PNG

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 24, 2018 Dec 24, 2018

Copy link to clipboard

Copied

JavaScript is case-sensitive.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 24, 2018 Dec 24, 2018

Copy link to clipboard

Copied

lol. guilty of overlooking the simple because i convinced myself the answer was complex.

thank you for your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2020 Apr 13, 2020

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2020 Apr 13, 2020

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. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 22, 2021 Sep 22, 2021

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! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

Move the code to the Will Print event of the document, under Tools - JavaScript - Set Document Actions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

LATEST

Perfect!  Thank you for your prompt assistance.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines