Need a Action to run insert item on repeating tbl - InfoPath Dev
in

InfoPath Dev

Need a Action to run insert item on repeating tbl

Last post 12-07-2006 09:11 AM by blackduke77. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 12-07-2006 08:00 AM

    Need a Action to run insert item on repeating tbl

    Hi I hope you can help.
    We are creating a Time and attendance form, we have connected the form to SQL and can query and submit data in a repeating table. When the user opens the form he gets a repeating table where they can see 7 rows, one for each day of the week, they have the option of selecting a previous week and running the query to amend historical data (works) however if they select a week where there is no data, ie they are entering data, the repeating table collapses to 0 rows with a insert row option(great), what I am trying to do is get the form to run the query but keep the repeating table with 7 rows, is there a action I can run, or some code, I am very new to managed code.
  • 12-07-2006 08:13 AM In reply to

    Re: Need a Action to run insert item on repeating tbl

    Hi blackduke77 and welcome to the forum!

    There are a couple of ways to do this with code. I will provide some psuedo code below


    IXMLDOMNode nParent = thisXDocument.DOM.selectSinglNode( "/my:myFields/my:group1" );

    // Create a sample node
    IXMLDOMNode nSampleChild = nParent.FirstChild.cloneNode(true);

    // Remove the old nodes
    ((IXMLDOMSelection)nParent.selectNodes( "my:group2" )).removeAll();

    // Create new nodes

    string[] days = { "M", "T", ... , "S" };

    for( int i = 0; i < 7; i++ )
    {
    IXMLDOMNode nNewDay = nSampleChild.cloneNode(true);
    nNewDay.selectSingleNode( "my:Day" ).text = days;
    nParent.appendChild( nNewDay );
    }


    One problem with this is that the node might not be there when you try to make the sample. To solve this you could load the XML from the template.xml:

    IXMLDOMDocument tempdom = thisXDocument.CreateDOM();
    tempdom.async = false;
    tempdom.validationOnParse = false;
    tempdom.load( "template.xml" );


    If all else fails you can also get the sample node in the OnLoad event, store it in a global variable, and clone it as desired. Hope this helps, good luck!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 12-07-2006 09:11 AM In reply to

    Re: Need a Action to run insert item on repeating tbl

    Thanks for the great responce and so fast, however my colleague and I have no idea what it all means..... Would you be able to help me out :) could be worth some beer!!!

    Thanks
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.