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

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!

https://lh3.googleusercontent.com/-cOK2xRdwVFw/V6tJmRgdyUI/AAAAAAAAAXI/m3vtfEuYgdUejZ4TN3UGpd_sreGDbaPJACLcB/s1600/repeat%2Bgroup.png

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

··· On Wed, Aug 10, 2016 at 11:34 AM, Stew Stremel wrote:

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!

https://lh3.googleusercontent.com/-cOK2xRdwVFw/V6tJmRgdyUI/AAAAAAAAAXI/m3vtfEuYgdUejZ4TN3UGpd_sreGDbaPJACLcB/s1600/repeat%2Bgroup.png


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.

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,

··· On Wednesday, August 10, 2016 at 10:38:34 AM UTC-7, Clayton Sims wrote:

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

On Wed, Aug 10, 2016 at 11:34 AM, Stew Stremel <stews...@gmail.com <javascript:>> wrote:

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!

https://lh3.googleusercontent.com/-cOK2xRdwVFw/V6tJmRgdyUI/AAAAAAAAAXI/m3vtfEuYgdUejZ4TN3UGpd_sreGDbaPJACLcB/s1600/repeat%2Bgroup.png


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-user...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/d/optout.