Skip to main content
Alliosaaa
Inspiring
October 9, 2017
Answered

Print Field Calculation Order in JavaScript Console?

  • October 9, 2017
  • 2 replies
  • 1243 views

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?

This topic has been closed for replies.
Correct answer try67

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;

}

2 replies

Joel Geraci
Community Expert
Community Expert
October 9, 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.

try67
Community Expert
Community Expert
October 9, 2017

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

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 9, 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;

}

try67
Community Expert
Community Expert
October 9, 2017

Not possible with a script, no, unfortunately.