In several places we use custom multiple choice lookup tables to list and
select from child cases filtered by the current case - for example, listing
household members for the current household.
Where we’ve done that the filter looks like this:
index/parent = instance(‘commcaresession’)/session/data/case_id
We’d like to do this where the cases to select from share a parent with the
current case - for example, listing household members as part of a farm
form, where the farm is also a child of the household.
I’ve tried a few variations of how I think the filter for this should look
but they don’t seem to work. Any tips?
Thanks in advance for any help.
Amber,
I’d recommend breaking this into two parts:
For the first, you’ll need to get the parent_id based on the current case_id
Then, you’ll need to filter the case_db for cases that have this parent_id
value
The first part would look something like (pseudo code):
instance(‘casedb’)/casedb/case[@case_id=instance(‘commcaresession’)/
session/data/case_id]/parent_id
The second part would look like:
instance(‘casedb’)/casedb/case/[parent_id=($value_from_above)]
Hope this helps.
Cheers,
Will
···
On Tue, Aug 9, 2016 at 7:06 AM, wrote:
In several places we use custom multiple choice lookup tables to list and
select from child cases filtered by the current case - for example, listing
household members for the current household.
Where we’ve done that the filter looks like this:
index/parent = instance(‘commcaresession’)/session/data/case_id
We’d like to do this where the cases to select from share a parent with
the current case - for example, listing household members as part of a farm
form, where the farm is also a child of the household.
I’ve tried a few variations of how I think the filter for this should look
but they don’t seem to work. Any tips?
Thanks in advance for any help.
–
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.
Thanks Will, that’s fantastic. I’ll give it a go.