Filtering Nested Repeating Tables - InfoPath Dev
in

InfoPath Dev

Filtering Nested Repeating Tables

Last post 06-08-2016 05:06 PM by Hilary Stoupa. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 06-07-2016 05:19 AM

    Filtering Nested Repeating Tables

     Hi there - I'm using InfoPath 2010, and want to filter a nested repeating table (the inside table) based on a value in the primary table (the outside table).

    I've got two DataConnections - "Parent Questions" and "Child Questions". "Parent Questions" contains two columns: Question_Number and Question. "Child Questions" contains three columns: Question Number, Parent Number and Question. For example:

    Parent Questions

    1    Did you do a?

    2    Did you do b?

    3    Did you do c?

    Child Questions

    1a   1   Did you also do a1

    2a   2   Did you also do b1

    2b   2   Did you also do b2

     

    I've added Parent Questions as a repeating table (the outside table). I've embedded Child Questions (inside table, in yellow within the Parent Question Repeating table:

     

    I'd like to filter the Child Question based on the Parent Question; so, only 1a appears under Question 1; only 2a and 2b appear under Question 2, and nothing appears under Question 3 (this is needed since question 1 will be a screening question: if the answer is "yes" show 1a; if not, do not show 1a). I've set up a filter to hide the Child Question if Parent Number(in child) != Question Number(in parent).

    This works for the first Parent row; but not in subsequent rows. The 'Parent Number' stays as 1 in subsequent rows, and does not correctly reflect the actual Parent Number:

     

      

    Here's my filter expression:

    number(xdXDocument:GetDOM("Parent Questions")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Question_Number) != number(d:Child) 

    Any thoughts on how to modify the reference to Parent Question so it correctly matches the Parent row that it is in?

    Thanks!
    Rob 

     

     


  • 06-07-2016 03:58 PM In reply to

    Re: Filtering Nested Repeating Tables

     What does your form schema look like? Care to attach a copy of your template under the Options tab in a reply?

    Hilary Stoupa

  • 06-07-2016 05:14 PM In reply to

    Thanks Hilary! I've attached the file; and included in the document the content of the two SharePoint lists that are referenced; as well as a screen shot of my previewer result. The "Parent Question" number stays equal to 1 in each row of the table, instead of increasing with each row in the parent table.

    Hope it makes sense what I'm trying to do. Thanks so much for the help! 

  • 06-08-2016 08:16 AM In reply to

    Re: Filtering Nested Repeating Tables

     Ouch, this is what I was afraid of. The issue with this is that you just can't create a filter here that will work. I'm sorry - I've tried this in the past, where the data comes from two separate data sources like this, and the best work around I've arrived at is using faux hide / show sections, where I query the secondary data on the "show" button for the child list for only the items belonging to that specific parent. You just need to display these questions? Because (and forgive me if I am stating something obvious to you) if you want users to be able to save any answers, your going to need those in you main data source.

    I think what I would probably do is go ahead and flatten these two lists in SharePoint if the data is just going to be displayed on the form - we can use a preceding sibling formula to make it display in the manner you wish. But if your end goal is to collect answers to these questions, I think it would be best to discuss that first.... 

    Hilary Stoupa

  • 06-08-2016 10:11 AM In reply to

    Thanks Hilary - it's good to (at least) get confirmation that it's not possible.

    Regarding saving the data - I'm going to be saving this as a library file (along with a couple of concat'd fields), so I'm okay with the data not being directly available outside of the completed form.

    My main goal is to have the answer to a Parent question result in the appearance of Child questions. So, if Question 1 is "Yes", then show 1a, 1b, etc.; if Question 1 is "No", then hide 1a, 1b, etc. Therefore, each row with have a "Yes" checkbox: if yes, show children; if no, hide children. I've got this working fine with questions hard-written into the form and associated child sections; but I was hoping to make a 'blank' form that could be fully populated via lists (that way, non InfoPath folks can create their own cascading forms).

    I initially had a single, flat list that included Parent and Child questions (see my new attachment). But what I couldn't figure out was how to hide the child rows. In text, the rule is: if the field Yes in the Parent row equals "yes"; and the field Child =equals the field Question Number, then show; otherwise, hide. I thought briefly about the preceding-sibling formula, but I don't really know the correct syntax of that one (I've used it, but only when copy/pasting from an example!), and I didn't know if could accommodate multiple Child questions (e.g., 1a has 1 as the immediate predecessor; but 1b has 1a as the predecessor. Maybe something like: show the row if the preceding row has Question Number = Child or Child = Child).

    Anyway - I really appreciate you thinking about this. I've attached an updated example; if you have any thoughts (or a good link) to preceding-sibling syntax, that would be awesome!!  

      

  • 06-08-2016 10:31 AM In reply to

    Re: Filtering Nested Repeating Tables

    I'm not being clear. Unless the data the user enters is in the main data source, the data won't save. I'm guessing you want the user to answer each question?
    Hilary Stoupa

  • 06-08-2016 11:12 AM In reply to

    Re: Filtering Nested Repeating Tables

    Ah - oh boy. You are right (embarrassed) - I'm not sure what I was thinking. Now - guess I could use some programming to populate a main data source repeating table with the list data - I have done that before, so I think I can work that part out - and then I could put a true yes/no option button into the form, instead of the 'dummy' check boxes. (this will not be a browser form).

    Then I'd still need a rule to hide the Child rows until the associated Parent row has the "Yes" column equal to yes.

    - OR -  

    I could put two main data source repeating tables (Parent and Child); populate them both by code based on two different secondary sources, and then use rules like I had in my original post to show/hide Child questions. Since the data in the main data source, I assume the previous rules would work.

    I think I would prefer option 1 - it would be 'cleaner' for a regular user to populate one flat SP list versus two lists, if I could get the preceding-sibling rules to work.

    Sorry - this post has turned into a brainstorming exercise! Thanks again for the help, and any suggestions you may have on the preceding-sibling rule.... 

     

  • 06-08-2016 11:22 AM In reply to

    Re: Filtering Nested Repeating Tables

    If you are going to use code to populate the main data source, I'd make the main data source reflect the true data structure. I'd have a parent group, with the repeating child group inside - then use code to populate the parent item and the child items for that parent. This makes layout simple - your layout now matches your data structure - and doesn't really make the code much more complex - you'll query your two lists for data, and as you create and populate each parent, you then can populate children for that parent. I will take a look at your other form later today tho and help w/ a preceding-sibling example. :)
    Hilary Stoupa

  • 06-08-2016 05:06 PM In reply to

    Re: Filtering Nested Repeating Tables

    I took a look at your flattened data - and from the sample data, you wouldn't really need any special formatting, right? The parent doesn't repeat for each child. I'd just add a little expression box as some padding to indent the child question number, hide if child != 1, for example....
    Hilary Stoupa

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