Ok, so after weeks of working on this, and reading every possible post (multiple times) on inserting into repeating tables(here & Google Groups), I'm giving in and posting my problem.
I am trying to insert into an Access database basically a "receipt" of everything that was chosen on the form. The form already updates other tables just fine, but I need it to insert a row in my ETF table each time the form is filled out & submitted. I couldnt seem to insert a new row in the ETF table, as Infopath always tried to update a current record in the ETF table that matched a foreign key, since I queried for the updates in other tables. I noticed when I placed my datafields on my form as a repeating table, I could insert manually values into the ETF table, and when I hit submit, my form would update the other tables like it always did, but it inserted a new row in the ETF. This is when I realized I needed to programmatically insert into my ETF datafields, and if need be hide the repeating table, but I'm thinking I won't need the repeating table at all and will eventually just insert into the table, after this code is right.
Any help would greatly be appreciated! Any questions let me know!
My code gets stopped at row = row.cloneNode(true);
with the error - 'null' is null or not an object
Here is what I have so far-
TEMPLATE.xml ->
<?xml version="1.0" encoding="UTF-8"?>
<?mso-infoPathSolution name="urn:schemas-microsoft-
com:office:infopath:New-Folder--2-:-dataFormSolution"
href="manifest.xsf" solutionVersion="1.0.0.20" initialView="View 1"
productVersion="11.0.6565" PIVersion="1.0.0.0" ?>
<?mso-application progid="InfoPath.Document"?>
<dfs:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields"
xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-22T15:18:03"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
<dfs:queryFields>
<q:DSCP CID="" TeamID=""></q:DSCP>
<q:Labor CID="" PLC=""></q:Labor>
<q:Salary CID="" Rate="" FLSA=""></q:Salary>
<q:ETF ETFID="" CID="" StatusID="" ChangeID=""
OldTaskID="" OldPLC="" OldFLSA="" OldRate="" NewTaskID="" NewPLC=""
NewFLSA="" NewRate="" PayChangeDate="" OtherChangeDate=""></q:ETF>
</dfs:queryFields>
<dfs:dataFields>
<d:DSCP CID="" TeamID="">
<d:Labor CID="" PLC=""></d:Labor>
<d:Salary CID="" Rate="" FLSA=""></d:Salary>
<d:ETF ETFID="" CID="" StatusID=""
ChangeID="" OldTaskID="" OldPLC="" OldFLSA="" OldRate="" NewTaskID="" NewPLC="" NewFLSA="" NewRate="" PayChangeDate=""
OtherChangeDate=""></d:ETF>
</d:DSCP>
</dfs:dataFields>
<my:Local my:ProposedTeamID="">
........(many fields)
</my:Local>
---------------------------------------------------------------
CODE->
//<namespacesDefinition>
XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields"
xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-22T15:18:03"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
//</namespacesDefinition>
function CTRL174_7::OnClick(eventObj)
{
var doc = XDocument.DataObjects("DSCP");
doc.DOM.setProperty("SelectionNamespaces",
'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" '
+ 'xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" ' + '
xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');
var row = doc.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:DSCP/d:ETF");
row = row.cloneNode(true);
row.selectSingleNode("/dfs:myFields/dfs:dataFields/d:DSCP/d:ETF/@CID").text = "TEST";
//Rest of fields in repeating table would be inputted here, just like CID was above.
var parent = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:/dataFields/d:DSCP");
parent.appendChild(row);
}