Copy link to clipboard
Copied
Is it possible to use a loop in the debugger console to set the custom calculation of multiple fields to a script? I believe I have the right idea here, but I need help making my loop. I want to work through every field with "Quant" in its name (I have Quant A1, Quant A2, Quant B1, etc.). They will all have the same calculation script.
for (var i = 0; i < this.numFields; i++){
if(/*need logic here to match "Quant" in the field name*/){
this.getField(/*field*/).setAction("Calculate", /*my custom calculation script will be here */);
}
}
I'm just unsure what the logic is to check the beginning of each field name for "Quant". Thank you, community!
I figured out what I was looking for. It was the string.match() function, usuing regular expressions. This instance ignores case and should (hopefully) be grabbing any field whose name contains "quant".
for (var i = 0; i < this.numFields; i++){
var f = this.getField(getNthFieldName(i));
if(f.name.match(/quant/i) != null){
f.setAction("Calculate", "test");
}
}
Copy link to clipboard
Copied
I figured out what I was looking for. It was the string.match() function, usuing regular expressions. This instance ignores case and should (hopefully) be grabbing any field whose name contains "quant".
for (var i = 0; i < this.numFields; i++){
var f = this.getField(getNthFieldName(i));
if(f.name.match(/quant/i) != null){
f.setAction("Calculate", "test");
}
}