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

Trying to locate duplicate form fields

Explorer ,
May 22, 2020 May 22, 2020

I am troubleshooting an Acrobat form with a lot of Yes/No checkboxes. I've created separate group names for each set of boxes, but apparently there are duplicates somewhere, for when I tried to make copies of the fields (to edit afterwards) I got the message "Cannot create multiple copies of this selection. One or more fields in the selection have duplicated in this form."

 

So I searched the community here and found a javascript to locate duplicate fields:

for (var i=0; i<this.numFields; i++) {
    var f = this.getField(this.getNthFieldName(i));
    if (f==null) continue;
    if (f.type=="text" && typeof f.page=="object") {
        console.println(f.name + ":" + f.page);
    }
}

and ran it in the Javascript Consol/Debugger, but I would get the error message:

SyntaxError: syntax error
1:Console:Exec
undefined

so am I doing something wrong? 

 

Each button already has a run javascript action on mouse up, could that be interfering somehow?

if (event.shift) event.target.value = "Off"

 Any help would be greatly appreciated.

TOPICS
General troubleshooting , PDF forms
3.3K
Translate
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
2 ACCEPTED SOLUTIONS
Community Expert ,
May 23, 2020 May 23, 2020

Select the whole code and execute it.

 

The code will find duplicate form text fields.

View solution in original post

Translate
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 ,
May 25, 2020 May 25, 2020
LATEST

Correct. You can remove this part of the code (which I believe I wrote, by the way) to process all fields, not just text fields:

f.type=="text" && 

However, this means that it will list all radio-buttons and check-boxes which have more than one widget in the group.

To avoid that you can replace the above with this:

f.type!="radiobutton" && f.type!="checkbox" &&

Then it will report about duplicate fields of all other types, except those two.

View solution in original post

Translate
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 ,
May 23, 2020 May 23, 2020

Select the whole code and execute it.

 

The code will find duplicate form text fields.

Translate
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 ,
May 23, 2020 May 23, 2020

You'll find a tutorial here on using the console window:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

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

Translate
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
Explorer ,
May 25, 2020 May 25, 2020

Ok, I ran it and it came back with "undefined" so that would mean no duplicate fields?

Translate
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 ,
May 25, 2020 May 25, 2020

Then you have no duplicate text fields.

Translate
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 ,
May 25, 2020 May 25, 2020
LATEST

Correct. You can remove this part of the code (which I believe I wrote, by the way) to process all fields, not just text fields:

f.type=="text" && 

However, this means that it will list all radio-buttons and check-boxes which have more than one widget in the group.

To avoid that you can replace the above with this:

f.type!="radiobutton" && f.type!="checkbox" &&

Then it will report about duplicate fields of all other types, except those two.

Translate
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