Dear Robert,
Please first make sure that your form is dynamic, I mean, just create an Add button that clicking on it you will be able to create more rows. (there are many examples in the forum)
Once you got it you will have to create a function like this, please note that I have copied an pasted them without changing the objects, maybe you will need to change some of them, be careful
function populateDB()
{
var sDataConnectionName = "Oracle"; // name of the data connection to get the data from. Note the data connection will appear in the Data View.
// Search for sourceSet node which matchs the DataConnection name
var nIndex = 0;
while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName)
{
nIndex++;
}
var oDB = xfa.sourceSet.nodes.item(nIndex);
oDB.open();
oDB.first();
// Search node with the class name "command"
var nDBIndex = 0;
while(oDB.nodes.item(nDBIndex).className != "command")
{
nDBIndex++;
}
// Backup the original settings before assigning BOF and EOF to stay
var sBOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("bofAction");
var sEOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("eofAction");
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF", "bofAction");
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF", "eofAction");
// Search for the record node with the matching Data Connection name
nIndex = 0;
while(xfa.record.nodes.item(nIndex).name != sDataConnectionName)
{
nIndex++;
}
var oRecord = xfa.record.nodes.item(nIndex);
// Find the node representing the columns in the table
var oCol1Node = null;
var oCol2Node = null;
var oCol3Node = null;
for(var nColIndex = 0; nColIndex < oRecord.nodes.length; nColIndex++)
{
if(oRecord.nodes.item(nColIndex).name == "C1") // column 1
{
//app.alert(oRecord.nodes.item(nColIndex))
oCol1Node = oRecord.nodes.item(nColIndex);
}
else
{
if(oRecord.nodes.item(nColIndex).name == "C2") // column 2
oCol2Node = oRecord.nodes.item(nColIndex);
else
{
if(oRecord.nodes.item(nColIndex).name == "C3") // column 3
//app.alert(oRecord.nodes.item(nColIndex))
oCol3Node = oRecord.nodes.item(nColIndex);
}
}
}
var secuencial;
var secuencial_ant;
var oNewRow;
secuencial_ant = 0;
while(!oDB.isEOF())
{
// create new row in Table1
if (oCol3Node.value != secuencial_ant)
oNewRow = xfa.form.Formulario1.Linea_detalle.Bordes.Campos.instanceManager.addInstance(false);
app.alert(oCol1Node.value);
app.alert(oCol2Node.value);
app.alert(oCol3Node.value);
rellenaCampo(oCol1Node.value ,oCol2Node.value);
secuencial_ant = oCol3Node.value;
oDB.next();
}
// Restore the original settings
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sBOFBackup, "bofAction");
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sEOFBackup, "eofAction");
// Close connection
oDB.close();
}
function rellenaCampo(NombreCampo, ValorCampo)
{
var obj = xfa.form.resolveNode(NombreCampo);
if (obj != null)
obj.rawValue = ValorCampo;
}
Its read an Oracle DB table named T1 with three colums, name of the field, value and position into the list of fields (row 0, row 1, etc).
The second function just fill the field, the parameters are FieldName and FieldValue.
This codes are from the forum, I had your same problem and searching in it I founded it.
BR