Accessing Repeating Section in a secondary data source - InfoPath Dev
in

InfoPath Dev

Accessing Repeating Section in a secondary data source

Last post 03-14-2011 09:02 PM by qwerty. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-14-2011 02:39 PM

    Accessing Repeating Section in a secondary data source

     

    I have a form that contains similar types of information that appears in different sections of the form. Once a user is done filling out that form I want to grab all the like information and consolidate it into a single repeating table.

    I've found a few good resources that shows me how to access and add values to repeating tables/sections in the main data source, but I'm having issues getting it to work pointing to a secondary data source. 

    Here's an example of code that works in the main data source to add a row to a repeating table (note: I did not include the part that writes the actual values to the row)

    string myNamespace = NamespaceManager.LookupNamespace("my");
    using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode(
    "/my:myFields/my:group1", NamespaceManager).AppendChild())

    I have 2 questions

    • 1) Does the secondary data source use the "My" NameSpace?
    • 2) My secondary data source is a web service named ReceiveData. When I added it to my data connections, under data source it looks as follows:

    myFields

            queryFields

                            tns:Group1

                                            :Group2

                                                            :item

                                                                            Field1

                                                                            Field2

                                                                            Etc

    I changed the above code to be the following:

     

    string myNamespace = NamespaceManager.LookupNamespace("my");

    DataSource ds = DataSources["ReceiveData"];

    Using (XmlWriter writer = ds.CreateNavigator().SelectSingleNode("/my:myFields/my:queryFields/my:tns:group1/my::Group2", NamespaceManager).AppendChild())

     

    I get /my:myFields/my:queryFields/my:tns:group1/my::Group2 contains an invalid token error which I'm assuming is because there are extra : in the names of the elements returned by the web service.

     

    I'm not sure where to go from here, I'm beyond the realm of documentation

     

    Any Ideas?

  • 03-14-2011 09:02 PM In reply to

    Re: Accessing Repeating Section in a secondary data source

    Hi dlcj21,

    This can be done without code. First, create one repeating table (@table), and then put copies of it into the different sections. You'll have to add an extra field to your repeating table (no need to display it in the form). Use the Default Values dialog box (Tools > Advanced > Default Values in IP2003 / IP2007) to create as many initial occurrences of the repeating table as you need, and then add a default value to your extra field for each occurrence like "Section 1" or "Section 2." Then add filtering to each copy of @table like "Display data if: @extraField != <Section Number>." Then you will need to specify for each of the copies of @table that "User cannot insert or delete this control."

    That will work for you if none of the items in your sections that will go into @table need to repeat. If they do, then you will have to find a way to make new occurrences of @extraField correspond to the repeating table they were inserted from. I can't think of a (codeless -- I'm not much good with code) way to do that offhand. If there is, it would be with a default value formula.

    Hope this helps!

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