Conditional script isn't working

I apologize if this is really basic but I have trouble with nested tables and indexing. I am trying to write a condition to hide two rows in a table if the field 'Name9" is equal to N/A. My script looks like this. It doesn’t work and it doesn’t give me any errors. I tries using record.tables.AB[index].tables.Advisor[0] ["Name9]; and that didn’t work either.

var advisor = record.tables.AB[0].tables.Advisor[“Name9”];

if (advisor == “N/A”) {
results.attr(“data-conditional”, “”);
results.hide();
} else {
results.show();
}

I’m sure this is simple but I can’t get this to work. I also used results.each(function(index) { befroe my var line and that didn’t work either.

Thank You

1 Like

How about trying this:

record.tables.AB[index].tables.Advisor[0].fields[“Name9”]

Ok - my condition works but I get the following errors on my var line -

cannot read property ‘tables’ from undefined
record index ‘2’ is out of range

Well your index is applied to the parent Table (i.e. AB), but maybe you’re actually tooking to apply it to the Advisor nested table?

Difficult to propose a definitive answer without seeing exactly what you have, but if you want to loop through all the Name9 fields in the Advisor table, then you’d use something like:

record.tables.AB[0].tables.Advisor[index].fields[“Name9”]