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

Print Field Calculation Order in JavaScript Console?

Explorer ,
Oct 09, 2017 Oct 09, 2017

I have an enormous amount of calculated fields, and am trying to audit them to make sure everything is as it should be. It would be easiest for me if I could copy and paste the list into excel to better plan the hierarchy of the fields. Is there a way to print the field calculation order in the javascript console?

TOPICS
Acrobat SDK and JavaScript
1.1K
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

correct answers 1 Correct answer

Community Expert , Oct 09, 2017 Oct 09, 2017

As an apology, I wrote the code that does it for you:

var fields = [];

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.calcOrderIndex>=0) {

        fields.push(f);

    }

}

fields.sort(sortByCalcOrderIndex);

for (var i=0; i<fields.length; i++) {

    console.println(fields.name);

}

function sortByCalcOrderIndex(a,b) {

    return a.calcOrderIndex-b.calcOrderIndex;

}

Translate
Community Expert ,
Oct 09, 2017 Oct 09, 2017

Not possible with a script, no, unfortunately.

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 ,
Oct 09, 2017 Oct 09, 2017

Yes it is.

You can loop through the fields adding each Field with a calcOrderIndex property greater than -1 to an array. Then use the Field Object calcOrderIndex to sort the fields based on the calcOrderIndex property, then print their names to the console.

If the calcOrderIndex = -1, it's not a calculated field.

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 ,
Oct 09, 2017 Oct 09, 2017

Sorry, my mistake. I was thinking about the tab order.

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 ,
Oct 09, 2017 Oct 09, 2017

As an apology, I wrote the code that does it for you:

var fields = [];

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.calcOrderIndex>=0) {

        fields.push(f);

    }

}

fields.sort(sortByCalcOrderIndex);

for (var i=0; i<fields.length; i++) {

    console.println(fields.name);

}

function sortByCalcOrderIndex(a,b) {

    return a.calcOrderIndex-b.calcOrderIndex;

}

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 ,
Oct 26, 2017 Oct 26, 2017
LATEST

Oh! I just saw this- THANK YOU SO MUCH! This will save me so much time!

Thanks also to you Joel Geraci​!

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 ,
Oct 09, 2017 Oct 09, 2017

If the tab order is unspecified, you can use the upper left coordinate of the field rect to determine tab order. Unfortunately, there is no way to determine what the Tab Order setting is for that particular page.

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 ,
Oct 09, 2017 Oct 09, 2017

I really hope Adobe will implement a r/w tabOrderIndex property one of these days... It will save us form developers so much agony.

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 ,
Oct 09, 2017 Oct 09, 2017

I just want a generic JavaScript COS walker so that we don't have to wait for Adobe to do anything except that.

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 ,
Oct 09, 2017 Oct 09, 2017

One can always dream...

On Mon, Oct 9, 2017 at 10:56 PM, Joel_Geraci <forums_noreply@adobe.com>

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