Copy Data From One Repeating Table to Another - InfoPath Dev
in

InfoPath Dev

Copy Data From One Repeating Table to Another

Last post 08-02-2015 11:31 PM by donstephen. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-30-2015 02:27 PM

    Copy Data From One Repeating Table to Another

     

    Hello there,

    I hope this is the correct forum to post an issue that I'm trying to resolve. I'm trying to figure out how to send data from one repeating table to another.  Ideally I would like for the user to be able to select item(s) from Table A and has/have it transfer to Table B upon clicking on the Add button. Table A will have checkbox for user to select one or multiple items.

    I tried searching the web and found a few solutions using C#, but I'm still unable to get it to work correctly. When I run my codes, the system seems to freeze.  I'm still new to programming so any help you can provide is greatly appreciated.  Thanks!

     

    Structure:  Two Tables: Table A and Table B.  Table A has A1, A2, and A3 fields.  Table has B1, B2, and B3 fields.

    Code: 

     public void Add2_Clicked(object sender, ClickedEventArgs e)
            {
                XPathNavigator mainDS = MainDataSource.CreateNavigator();
                XPathNavigator selectedRow = mainDS.SelectSingleNode("/my:myFields/my:TableA/my:FieldsA[my:A1 = 'true']", NamespaceManager);

                while (selectedRow != null)
                {
                        string A1 = selectedRow.SelectSingleNode("/my:myFields/my:TableA/my:FieldsA/my:A1", NamespaceManager).Value;
                        string A2 = selectedRow.SelectSingleNode("/my:myFields/my:TableA/my:FieldsA/my:A2", NamespaceManager).Value;
                        string A3 = selectedRow.SelectSingleNode("/my:myFields/my:TableA/my:FieldsA/my:A3", NamespaceManager).Value;
                       
                        XmlDocument doc = new XmlDocument();
                        XmlNode FieldsB = doc.CreateElement("FieldsB", NamespaceManager.LookupNamespace("my"));
                       
                        XmlNode field = doc.CreateElement("B1", NamespaceManager.LookupNamespace("my"));
                        XmlNode node = FieldsB.AppendChild(field);
                        node.InnerText = A1;

                        field = doc.CreateElement("B2", NamespaceManager.LookupNamespace("my"));
                        node = FieldsB.AppendChild(field);
                        node.InnerText = A2;

                        field = doc.CreateElement("B3", NamespaceManager.LookupNamespace("my"));
                        node = FieldsB.AppendChild(field);
                        node.InnerText = A3;

                        doc.AppendChild(FieldsB);

                        MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:TableB", NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());
                }
                        selectedRow = mainDS.SelectSingleNode("/my:myFields/my:TableA/my:FieldsA[my:A1 = 'true']", NamespaceManager);
     
            }

     

     

     

     

    Filed under: ,
  • 08-02-2015 11:31 PM In reply to

    Re: Copy Data From One Repeating Table to Another

    Hi PhamD2015,

    I have here a sample form which shows how to copy repeating data onto another table. This sample shows two techniques, the first one copies the data using default data while the other appraoch uses qRules - this is an excellent tool you can use to perform various operations that can manipulate data on your form, if you wish to avoid writing code. I haven't tried code writing yet to perform this function, but hopefully the sample form attached is able to give you an idea. (download the XSN, right click, and view in design mode to see the techniques performed)

    Hope this helps.

    Don Stephen Lambatin / Support Engineer
    Qdabra Software
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.