Filtering a repeat group based on an earlier multiple choice question?

215 views
Skip to first unread message

Stew Stremel

unread,
Aug 10, 2016, 11:34:59 AM8/10/16
to commcare-users
Hello all,

I have a question on how to get a repeat group to filter based on an earlier multiple choice question (this is for commtrack supply chain if that makes a difference).

Question 1 - lookup table on a list of Programs.  Returns a single program id
Question 2 - repeat group to a fixture on the list of products.  Works until I attempt to reference the program for filtering from question 1

Query expression on the repeat group:

Works:   instance('products')/products/product/@id
Doesn't: instance('products')/products/product[./program_id=current()/../../../question1]/@id

Thoughts?  It seems like the repeat group gets built out at the time the form loads, not at the time that the repeat group is presented to the user.

Thanks!


Clayton Sims

unread,
Aug 10, 2016, 1:38:34 PM8/10/16
to commcare-users
Stew,

Unfortunately you are correct that the repeat group gets built out when the form loads, and not during form entry. This is a necessary step to ensure that there is internal consistency in the repeat structure. Say the multiple select has 4 choices, and you choose all 4, then fill out all 4 iterations. You then remove choice 1 and 3 from the multiple choice question, it's hard to convey to the form what data goes away.

The form builders tend to handle this is to handle any in form filtering by expanding the repeat group fully, then adding a group to the inside of each, which has a display condition tied to the multiple choice answer. That ensures that the repeat filters correctly, but also conveys to the form what to do if the multiple choice answer changes within the context of the form itself.

-Clayton

--
You received this message because you are subscribed to the Google Groups "commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stew Stremel

unread,
Aug 11, 2016, 4:58:40 PM8/11/16
to commcare-users
Ok - Thanks for letting me know.  I will give the technique you describe a shot and see if I can make that work for me.

Cheers,
To unsubscribe from this group and stop receiving emails from it, send an email to commcare-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages