I have a strange problem whereby I have a detail table that I am conditionally hiding entire rows if they meet a certain criteria
I have 2 rows almost identical, one conditional statement works correctly, the other always hides the row even though criteria doesn’t match…See below code
Working conditional statement (hides the entire row if code = 092)
results.each(function(index) {
var field, result = 0;
for(let i=0;i<record.tables.detail2.length;i++){
field = record.tables.detail2[i].fields["Code"];
if(["092"].indexOf(field) > -1) {
result += record.tables["detail2"][i].fields["ANoPostP"];
}
}
results.html(formatter.currency(result));
// Hide the parent (row)
if( field !== "092") {
this.parent().hide();
}
});
The below conditional statement always hides the row for some reason (should only hide the entire row if code does not = 091)
results.each(function(index) {
var field, result = 0;
for(let i=0;i<record.tables.detail2.length;i++){
field = record.tables.detail2[i].fields["Code"];
if(["091"].indexOf(field) > -1) {
result += record.tables["detail2"][i].fields["ANoPostP"];
}
}
results.html(formatter.currency(result));
// Hide the parent (row)
if( field !== "091") {
this.parent().hide();
}
});
They are exactly the same except that the 1st (working) code is checking for “092” and the second (non-working) code is checking for “091”
What am I missing?