Hi - I am trying to write a condition in a nested detail table. My data looks something like below
record
NewCharges
Detail
I have something like this -
results.each(function(index) {
var fee = record.tables[“NewInvoice”][0].feilds[FeeType];
var value = record.tables[“NewInvoice”][0].tables[“Detail”][0].fields[“MktValue”]; ( my issue seems to be in this structure)
if (fee == “CUSTODIAL FEES”) {
results.html(‘Mkt Val: $’ + value);
It is returning only the first value in the nested table. I always have trouble with the nested tables if it goes deeper than one level.
So close! You simply need to replace the [0] with the [index] value, in order to iterate through each result:
results.each(function(index) {
var fee = record.tables["NewInvoice"][0].feilds[FeeType];
var value = record.tables["NewInvoice"][0].tables["Detail"][index].fields["MktValue"];
if (fee == "CUSTODIAL FEES") {
results.html('Mkt Val: $' + value);
Thank you!! I tried that. There are 25 records and it only shows the last record for all. The condition works as it should as far as hiding and showing what it needs to. It just isn’t indexing through to show the correct 'mkt Value for each record. My complete code is below.
results.each(function(index) {
var fee = record.tables[“NewInvoice”][0].fields[“FeeType”];
var value = record.tables[“NewInvoice”][0].tables[“Detail”][index].fields[“MktValue”];
if (fee == “CUSTODIAL FEES”) {
results.html(‘Mkt Val: $’ + value);
} else if (fee == “ASSET BASED FEE”) {
results.html(‘$’ + value);
} else {
results.hide();
}});
Yeah… your results loop is iterating on one of the tables, not both. In your case, you’d need to have access to the index for the outer loop as well as the one for the inner loop. Since this will likely require you to share Data and resources, which is not something we should do in a public forum, I would advise you to open a Support call with our team so they can take a stab at it…