how to copy secondary data into multiple repeating tables in main ds? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

how to copy secondary data into multiple repeating tables in main ds?

Last post 05-01-2009 09:51 AM by rippedX. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-30-2009 02:45 PM

    how to copy secondary data into multiple repeating tables in main ds?

    Hi,

    I have a browser form which receives data from a sharepoint list. I am copying that data into a repeating table in the main ds. I need it copied into a total of 3 repeating tables (identical tables), and can't seem to do it.

    This is from a tutorial. I tried just making copies of the code with the correct names of the other tables, but an exception is thrown on this line: doc.AppendChild(group); that says there is already a document element.

    My additional tables are (2 columns/2 fields):

    /my:COBInquiry/my:group3/my:group4/my:field3 /my:COBInquiry/my:group3/my:group4/my:field4

    /my:COBInquiry/my:group5/my:group6/my:field5 /my:COBInquiry/my:group5/my:group6/my:field6

    Repeating table structure should end up being (this is simply InnerXml):

    AACSB AACSB

    AACSB AACSB

    AACSB AACSB

    Here is my code:

    public void FormEvents_Loading(object sender, LoadingEventArgs e)
    {
    XPathNavigator secDSNav = DataSources["ReferredBy"].CreateNavigator();

    // Retrieve the rows of the secondary data source
    // /dfs:myFields/dfs:dataFields/dfs:COBInquiryDataSource
    XPathNodeIterator rows = secDSNav.Select("/dfs:myFields/dfs:dataFields/dfs:COBInquiryDataSource", NamespaceManager);

    // Loop through the rows of the secondary data source and fill the repeating table
    while (rows.MoveNext())
    {
    string title = rows.Current.SelectSingleNode("@Title", NamespaceManager).Value;
    string displayname = rows.Current.SelectSingleNode("@DisplayName", NamespaceManager).Value;

    // Add the item to the repeating table
    AddItem(title, displayname);
    }

    // Remove the first empty item from the repeating table
    DeleteFirstEmptyItem();
    }

    private void AddItem(string title, string displayname)
    {
    XmlDocument doc = new XmlDocument();
    XmlNode group = doc.CreateElement("group2", NamespaceManager.LookupNamespace("my"));

    XmlNode field = doc.CreateElement("field1", NamespaceManager.LookupNamespace("my"));

    XmlNode node = group.AppendChild(field);

    node.InnerText = title;

    field = doc.CreateElement("field2", NamespaceManager.LookupNamespace("my"));

    node = group.AppendChild(field);

    node.InnerText = displayname;

    doc.AppendChild(group);

    MainDataSource.CreateNavigator().SelectSingleNode("/my:COBInquiry/my:group1", NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());
    }

    The end result I want is all the data in the splist split among all three tables...So if the splist has 32 entries, 10 would be in one table, 11 in another, and 11 in the last. If anyone also knows how to do this, programmatically in code, I would appreciate it a lot!
  • 05-01-2009 12:21 AM In reply to

    Re: how to copy secondary data into multiple repeating tables in main ds?

    Hey xRipped and welcome!

    We created qRules to help with these kind of issues. It's qRules and supports copying from external tables to internal ones *without code*. Simpler, less cost to you. Voila!

    To fix your code will require someone debugging it with the form. It'll take time. Maybe you can figure it out, but if you can't you could just buy a Qdabra.com support pack (under products) and get an hour or two of help. It'll cost money, but we can't give hours to everyone in the forum since we have lots of posts these days and we'd go out of business... hope you understand. You probably have some simple issue like the main node isn't being selected or something.

    By the way, you shouldn't be putting the group and field in the AddItem routine. Pass those in from above.

    Bottom line though: qRules enables this without code. And, it's free with documentation and videos on how to do that. Have fun.

    Patrick Halstead
    Project Manager at Qdabra
  • 05-01-2009 09:51 AM In reply to

    Re: how to copy secondary data into multiple repeating tables in main ds?

    Thanks for your response Patrick, I appreciate it! However, I was already referred to qRules and tried it, but found it does not fit my needs as it will not work in the on load event. Do you mean pass in the groups/fields in that I want to copy to? So I don't need to create them on the fly, just retrieve them from the main data source?
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.