Inserting into Repeating Table (Main Connection) - InfoPath Dev
in

InfoPath Dev

Inserting into Repeating Table (Main Connection)

Last post 04-13-2006 09:44 AM by Matt Faus. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-12-2006 01:54 PM

    • Queezy
    • Not Ranked
    • Joined on 02-13-2006
    • USA
    • Posts 4

    Inserting into Repeating Table (Main Connection)

    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);
    }
  • 04-13-2006 07:00 AM In reply to

    • Shyam
    • Not Ranked
    • Joined on 08-02-2005
    • Posts 10

    Re: Inserting into Repeating Table (Main Connection)

    Hello Queezy,

    You seem to be saying "row.cloneNode()" method is giving you error. Did you stop at this line in debugger and see what the type of "row" object is and its contents ? Looks like you are expecting it to be an IXMLDOMNode type. If it is, then can you check what is the xml in this node ?

    thanks, Shyam
    Shyam
    InfoPath Dev
    India
  • 04-13-2006 08:26 AM In reply to

    • Queezy
    • Not Ranked
    • Joined on 02-13-2006
    • USA
    • Posts 4

    Re: Inserting into Repeating Table (Main Connection)

    I added row to the QuickWatch in MSE.
    It shows row with a value of "null" and its type as "Object".
  • 04-13-2006 09:44 AM In reply to

    Re: Inserting into Repeating Table (Main Connection)

    You code is unable to clone the row because it can't find one. Even though your template.xml has an ETF row in, it might not have it there when the code runs due to querying the database and returning no results. This seems like the problem.

    I can't see any problems with the code, but if the selectSingleNode() is returning null then there is no row there. You need to figure out why that is and then you can clone it.

    Otherwise, you could try creating a node from scratch by using the createNode() function of the DOM and then populating it with your appropriate values.

    Check out these methods in the MSXML 5.0 SDK:
    createDocumentFragment()
    createElement()
    createNode()
    appendChild()
    replaceChild()
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.