Access table values from script

Hi,

I am trying to loop through the rows of a table in the current data record and load a snippet based on the Code field. All I get with the below code “text += overlayRow[0] + " | ";” is a list of numbers and not my codes, e.g. 0 | 1 | 2 | 3… this is the count of the rows in the table.

This code is running in a selector “Script”.

var text = “<p>Script”;

for (var overlayRow in record.tables.Overlays)
{
//var snippet = loadhtml(‘snippets/’ + overlayRow.Code + ‘.html’).toString();
text += overlayRow[0] + " | “;
//for (var dataRow in record.tables.Data)
{
// text += snippet.replace(”@" + dataRow.Code + “@”, dataRow.Data);
}
}

results.after(text + “</p>”);

Try this:

var text = "<p>Script";

for (var overlayRow in record.tables.Overlays) {
    text += record.tables.Overlays[overlayRow].fields.Code + " | ";
}

results.after(text + "</p>");