Lookup tables inside repeat groups

Hi All,

I have a series of lookup tables inside an open repeat group:

repeat
-dept: what dept do you live in
-com: what commune do you live in
-sc: what section communale do you live in

I’m trying to use filter the options for the lookup tables by previous
answers so that com is filtered by dept and sc is filtered by com and dept.

This works fine for the com field which is filtered by the choice for dept

However when I try to do the same for the sc field I get an error where it
tries to evaluate …/dept at the instance(sc)

I’ve take out one of the filters and no longer get the error.

Any thoughts would be great!

Best,

Nishant

Actually not even the filter for the com field is working…it doesn’t seem
like it is evaluating …/dept as anything

··· On Tuesday, August 30, 2016 at 1:53:12 PM UTC-5, Nishant Kishore wrote: > > Hi All, > > I have a series of lookup tables inside an open repeat group: > > repeat > -dept: what dept do you live in > -com: what commune do you live in > -sc: what section communale do you live in > > I'm trying to use filter the options for the lookup tables by previous > answers so that com is filtered by dept and sc is filtered by com and dept. > > This works fine for the com field which is filtered by the choice for dept > > However when I try to do the same for the sc field I get an error where it > tries to evaluate ../dept at the instance(sc) > > I've take out one of the filters and no longer get the error. > > Any thoughts would be great! > > Best, > > Nishant >

So I see that when I write the entire question location in the filter
section the query looks like this:

instance(‘cdc_comm’)/cdc_comm_list/cdc_comm[dept_id =
#form/questionnaire/Travel_Phone/trip_repeat/list/HH_travel_Dept]

but when I write …/HH_travel_Dept it comes out like this:

instance(‘cdc_comm’)/cdc_comm_list/cdc_comm[dept_id = …/HH_travel_Dept]

which seems to be causing the error since the “…” evaluates back to the
instance rather than the question list it is in.

Anybody know the proper syntax for this?

··· On Tuesday, August 30, 2016 at 1:53:12 PM UTC-5, Nishant Kishore wrote: > > Hi All, > > I have a series of lookup tables inside an open repeat group: > > repeat > -dept: what dept do you live in > -com: what commune do you live in > -sc: what section communale do you live in > > I'm trying to use filter the options for the lookup tables by previous > answers so that com is filtered by dept and sc is filtered by com and dept. > > This works fine for the com field which is filtered by the choice for dept > > However when I try to do the same for the sc field I get an error where it > tries to evaluate ../dept at the instance(sc) > > I've take out one of the filters and no longer get the error. > > Any thoughts would be great! > > Best, > > Nishant >

Hi Nishant,

Lookup table filters inside repeats are a bit confusing because the context
of the reference that you are making inside of the filter expression
actually resets to the context of the full form, meaning that a reference
to the form won’t automatically contextualize to the particular repeat
instance you are in.

In order to make the reference you mentioned, you’ll need to begin a
relative reference with a function, current(), this will make your
reference “start” at the context of the current question, so your filter
would be

dept_id = current()/…/HH_travel_Dept

Let me know if that doesn’t work.

-Clayton

··· On Tue, Aug 30, 2016 at 3:54 PM, Nishant Kishore wrote:

So I see that when I write the entire question location in the filter
section the query looks like this:

instance(‘cdc_comm’)/cdc_comm_list/cdc_comm[dept_id =
#form/questionnaire/Travel_Phone/trip_repeat/list/HH_travel_Dept]

but when I write …/HH_travel_Dept it comes out like this:

instance(‘cdc_comm’)/cdc_comm_list/cdc_comm[dept_id = …/HH_travel_Dept]

which seems to be causing the error since the “…” evaluates back to the
instance rather than the question list it is in.

Anybody know the proper syntax for this?

On Tuesday, August 30, 2016 at 1:53:12 PM UTC-5, Nishant Kishore wrote:

Hi All,

I have a series of lookup tables inside an open repeat group:

repeat
-dept: what dept do you live in
-com: what commune do you live in
-sc: what section communale do you live in

I’m trying to use filter the options for the lookup tables by previous
answers so that com is filtered by dept and sc is filtered by com and dept.

This works fine for the com field which is filtered by the choice for dept

However when I try to do the same for the sc field I get an error where
it tries to evaluate …/dept at the instance(sc)

I’ve take out one of the filters and no longer get the error.

Any thoughts would be great!

Best,

Nishant


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.

Hi Clayton,

Sorry for the delayed response. It works though with a bit more editing
since my question was within another question list within the repeat group.
I’m going to leave these two links here for people exploring this issue in
the future:

https://confluence.dimagi.com/display/commtrack/Building+Apps+for+CommCare+Supply#BuildingAppsforCommCareSupply-Howtorefertotheproductinarepeat?Theuseofcurrent()

Best,

Nishant

Nishant Kishore
Data Manager | Malaria Zero: The Alliance for a Malaria-free Haiti | CDC
RPCV: Nicaragua 2011-2014
nish.kishore@gmail.com
M: +18044371312
Skype: nishant.kishore

··· On Wed, Aug 31, 2016 at 8:56 AM, Clayton Sims wrote:

Hi Nishant,

Lookup table filters inside repeats are a bit confusing because the
context of the reference that you are making inside of the filter
expression actually resets to the context of the full form, meaning that a
reference to the form won’t automatically contextualize to the particular
repeat instance you are in.

In order to make the reference you mentioned, you’ll need to begin a
relative reference with a function, current(), this will make your
reference “start” at the context of the current question, so your filter
would be

dept_id = current()/…/HH_travel_Dept

Let me know if that doesn’t work.

-Clayton

On Tue, Aug 30, 2016 at 3:54 PM, Nishant Kishore nish.kishore@gmail.com wrote:

So I see that when I write the entire question location in the filter
section the query looks like this:

instance(‘cdc_comm’)/cdc_comm_list/cdc_comm[dept_id =
#form/questionnaire/Travel_Phone/trip_repeat/list/HH_travel_Dept]

but when I write …/HH_travel_Dept it comes out like this:

instance(‘cdc_comm’)/cdc_comm_list/cdc_comm[dept_id = …/HH_travel_Dept]

which seems to be causing the error since the “…” evaluates back to the
instance rather than the question list it is in.

Anybody know the proper syntax for this?

On Tuesday, August 30, 2016 at 1:53:12 PM UTC-5, Nishant Kishore wrote:

Hi All,

I have a series of lookup tables inside an open repeat group:

repeat
-dept: what dept do you live in
-com: what commune do you live in
-sc: what section communale do you live in

I’m trying to use filter the options for the lookup tables by previous
answers so that com is filtered by dept and sc is filtered by com and dept.

This works fine for the com field which is filtered by the choice for
dept

However when I try to do the same for the sc field I get an error where
it tries to evaluate …/dept at the instance(sc)

I’ve take out one of the filters and no longer get the error.

Any thoughts would be great!

Best,

Nishant


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.


You received this message because you are subscribed to a topic in the
Google Groups “commcare-users” group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/commcare-users/c8Q19LmPNCI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi there,

Please assist on where to insert a logic. i have a scenario that ward, and village are lookup tables inside a repeat group. One first iteration goes well, but the second iteration village returns the error below

XPath nodeset has more than one node [/data/beneficiaries_and_incident_information[1]/ward[1];/data/beneficiaries_and_incident_information[2]/ward[1]]; cannot convert multiple nodes to a raw value. Refine path expression to match only one node.