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.
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.
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;
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.