Using a script with a nested detail table

Hi - I am trying to create a table using nested tables in the datamapper based on repeat data. Fro example I need to create a table that looks like this.

PlanID
ClmStat $$ ##
ClmStat $$ ##
ClmStat $$ ##
PlanID
ClmStat $$ ##
ClmStat $$ ##

I have an example created by someone on here and I was trying to adjust that to fit my needs. I am unable to get it to work. I am new to javascript so I am sure I am not completely understanding what the script is doing. I am sure I haven’t placed the right tables or fields correctly while trying to adjust the script. Would anyone be able to help me?
I am attaching my sample data that I have so far.

Thanks

https://learn.objectiflune.com/qa-blobs/11126793015281228364.zip

I was able to solve this myself.

Hello, Sr

could you show me how to solved you this problem, I have a similar nested tables and I can´t solve the problem by myself.

Thank you

I found this solution myself. To help others here is how to do it:

// GET INDEXES OF CURRENT RECORDS FOR EACH TABLE
var currentP = record.tables.parts.length -1;
var currentS = record.tables.parts[currentP].tables.sections.length -1;
var currentI = record.tables.parts[currentP].tables.sections[currentS].tables.items.length -1;

// GET DESCRIPTION FIELD
var field = record.tables.parts[currentP].tables.sections[currentS].tables.items[currentI].fields.str_description;

Thank you very much ahaddad
Claudio

Howdy,

I know this is an old thread but I had a similar difficult nut to crack and I thought this would be helpful for folks:

For this example let’s say that we have two ‘Detail’ table records with three ‘Bom’ sub-table records each.

For the usual “results.each(function(index) {” syntax this would result in 6 total records and there was no easy way to iterate over the Detail table and the Bom sub-table with that syntax (since ‘index’ went from 0-5, instead of 0-1).

This was used in the Edit Script dialog with the Selector option and the Scope set to Result set.

idx = 0;
for (let i = 0; i < record.tables.detail.length; i++) {
bomLength = record.detail[i].bom.length;
for (let j = 0; j < bomLength; j++) {
wmsLocationId = record.detail[i].bom[j].Field_wmsLocationId;
QtyInventCalc = record.detail[i].bom[j].Field_ProdBOM_QtyInventCalc;
QtyInventCalc = Math.round(QtyInventCalc.toString().replace(/,/g, “”));
ItemId = record.detail[i].bom[j].Field_ProdBOM_ItemId;
field = “&nbsp&nbsp&nbsp&nbsp” + wmsLocationId + " - " + QtyInventCalc + " - " + ItemId;
results[idx].html(field);
idx++;
}
}

Have a great day!