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

Working in Acrobat pro have a fillable PDF where I want one field set to auto populate

Community Beginner ,
Oct 02, 2023 Oct 02, 2023

Copy link to clipboard

Copied

I have a fillable PDF where there is a column where I want to be able to auto populate sequentially the rest of the boxes in that field set based on the first field entry.Order number.png

TOPICS
How to , Modern Acrobat , PDF , PDF forms

Views

259

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 ,
Oct 02, 2023 Oct 02, 2023

Copy link to clipboard

Copied

Yes, this is possible with a script. From the image I'm assuming that the Order Number column is the one you want automatically populated?  Will the user always be starting on the first line, or can the auto numbering start at any line?  Does the user enter the order number? or is it automatically set from some other source?

 

 

 

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 ,
Oct 02, 2023 Oct 02, 2023

Copy link to clipboard

Copied

The first "order number" field will be manually filled and I wish for each order number field to increment by one to the bottom of the sheet. This whether the sheet starts at 1 or 511.

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 ,
Oct 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

Would someone be able to show me an example of a incremental couter script? I have tried a few things that I found on the internet and I am wondering if it's just my implementation that is failing me.

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 ,
Oct 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

The best approach is to use a Validate script on the "OrderNumber 1" field. Then make all the other OrderNumber fields read only. 

 

// Custom Validate script
if(Number.isInteger(Number(event.value))
{
   var nInc = Number(event.value);
   for(var i=2;i<=nRows;i++)
   {
       this.getField("OrderNumber " + i).value = ++nInc;
   } 
}
else
{
   event.value = "";
   app.alert("Entered Value must be an Integer");
}

 

 

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 ,
Oct 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

Thank you, I will try this in the morning! I'll report as to my results.

 

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 ,
Oct 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

Getting an error about bad syntax missing a ) after condition 3 at line 4....

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 ,
Oct 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

Correction, missing final ")" in first line

// Custom Validate script
if(Number.isInteger(Number(event.value)))
{
   var nInc = Number(event.value);
   for(var i=2;i<=nRows;i++)
   {
       this.getField("OrderNumber " + i).value = ++nInc;
   } 
}
else
{
   event.value = "";
   app.alert("Entered Value must be an Integer");
}

 

 

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 ,
Oct 04, 2023 Oct 04, 2023

Copy link to clipboard

Copied

As soon as I add a number to define the rows (changing nRows to say 24Rows) 

It returns " SyntaxError: identifier starts immediatelyu after numeric literal 

5: at line 6

 

😞

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 ,
Oct 04, 2023 Oct 04, 2023

Copy link to clipboard

Copied

I did not include a definition of "nRows". It has to be a number equal to the number of fields in the column

Here's an update.

// Custom Validate script
if(Number.isInteger(Number(event.value)))
{
   var nRows = 24;
   var nInc = Number(event.value);
   for(var i=2;i<=nRows;i++)
   {
       this.getField("OrderNumber " + i).value = ++nInc;
   } 
}
else
{
   event.value = "";
   app.alert("Entered Value must be an Integer");
}

 

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 ,
Oct 06, 2023 Oct 06, 2023

Copy link to clipboard

Copied

LATEST

Thank you for your help Mr. Parker. This has been a great learning experience. 

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