Copy a row from one repeting table to another - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Copy a row from one repeting table to another

Last post 07-25-2008 05:04 AM by eirike. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-25-2008 04:15 AM

    • eirike
    • Not Ranked
    • Joined on 07-25-2008
    • Posts 3

    Copy a row from one repeting table to another

    Infopath 2007 / C# / Visual Studio 

    Hi.

    I have been rewieving the post in this forum for some days now. But I still don't get it right. (I am newbie to infopath and programming.)

    My form has two repating tables(A and B). The table A(secondary datasource) is response to a call I make to a webservice. I have added a button to each row called "Add".

    Table B (main datasourse) has the same fields as the first repeating table + a button called "remove".

     I want to be able to "copy" the row from table A to table B with the "Add" Button. And remove rows from table B with the "Remove" Buttons.

     Please Help...

    Filed under: , ,
  • 07-25-2008 04:48 AM In reply to

    Re: Copy a row from one repeting table to another

    Hi,

    Can you go through below link  

     http://www.infopathdev.com/forums/t/5373.aspx

     I think it may help you

    Thanks,
    Sandhya


  • 07-25-2008 05:04 AM In reply to

    • eirike
    • Not Ranked
    • Joined on 07-25-2008
    • Posts 3

    Re: Copy a row from one repeting table to another

    Thansk for answering... 

    I have tried the following with my attributes, but get an error in VS, "Error 1 The name 'XDocument' does not exist in the current context" :

    Any Ideas?

    The following was just written from memory and not tested. There might be some syntax errors in it, but it should give you a good idea of what needs to be done:

    // Get a copy of the main DOM node.
    var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:PrimaryDataSource").cloneNode(true);

    // Clear the main DOM nodes.
    XDocument.DOM.selectNodes("/my:myFields/my:PrimaryDataSource").removeAll();

    // Copy nodes from 2DS to main DOM.
    var nodes = XDocument.GetDOM("SecondaryDataSource").selectNodes("/myFields/dataFields/SecondaryDataSource"); // Note: need to supply the correct namespace per element in this XPath.
    foreach(var node in nodes)
    {
     clone.selectSingleNode("my:Field1").text = node.selectSingleNode("Field1").text;
     clone.selectSingleNode("my:Field2").text = node.selectSingleNode("Field2").text;
     clone.selectSingleNode("my:Field3").text = node.selectSingleNode("Field3").text;

     XDocument.DOM.selectSingleNode("my:myFields").appendChild(clone.cloneNode(true));
    }

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