Fixtures filtering by value in form

37 views
Skip to first unread message

Tim

unread,
Apr 4, 2014, 11:06:55 AM4/4/14
to commcar...@googlegroups.com
Hi,

I have been experimenting with fixtures and have the example working.

In my use case I want to select a value from a large table by row then field.

I have the row syntax i.e. instance('districts')/district_list/district[1]/name this gets me the row by number and the field.

I would like to replace the number and the field with values generated in the form. i.e. instance('districts')/district_list/district[/data/rownumber]//data/fieldname.

XPath isn't my forte some any help much appreciated.

Thanks in advance

Tim






Cory Zue

unread,
Apr 6, 2014, 7:58:06 AM4/6/14
to commcar...@googlegroups.com
Hi Tim,

See the "Filtering the ItemSet" section here: https://help.commcarehq.org/pages/viewpage.action?pageId=12222793

Cory


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

Tim Butler

unread,
Apr 6, 2014, 8:15:35 AM4/6/14
to commcar...@googlegroups.com

Hi Cory,

Thanks for this.

Looking at the filter, that allows me to filter by value in a field. What I am looking to do is to get a value from a row/field intersection, much like vLookup in excel or the value from a place in an array i.e. array[2,2].

I am sure it's not that hard just can't get my head around it!

Best

Tim

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/fU0JpONA9vc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to commcare-user...@googlegroups.com.

William Pride

unread,
Apr 6, 2014, 3:09:19 PM4/6/14
to commcar...@googlegroups.com
Tim,

If I'm understanding correctly you want to select a fixture entry based both on its row number and a value in one of its fields. In that case, you'll want to use something like this

instance('districts')/district_list/district[/data/rownumber]/data/[fieldname=value_from_form]/field_you_want

Please let me know if I'm misunderstanding you or this isn't clear enough.

Best,
Will

Tim Butler

unread,
Apr 6, 2014, 4:35:21 PM4/6/14
to commcar...@googlegroups.com

Hi Will,

My understanding of this says

instance('districts')/district_list/district[/data/rownumber] gives me the row,

the /data/[fieldname=value_from_form]/ gives me the column 

and the last is the result field_you_want?

I will give this a go tomorrow.

Thanks for the help.

Best

Tim

Tim

unread,
Apr 7, 2014, 6:13:02 AM4/7/14
to commcar...@googlegroups.com
Hi Will

I have now got to the following:

instance('districts')/district_list/district[number(/data/rownumber)]/name
with the number wrap I get the correct row! :)

With this I get the desired result.

For the second half I am still confused. The /data/[fieldname=value_from_form]/field_you_want part I cannot make to work. 

I understand that I am selecting a field by name what I don't understand is the actual syntax. So if I had a single drop down name fieldname1 that had name and state_id as options how do I put that in place of name in the above?

Thanks for your patience.

Tim

William Pride

unread,
Apr 8, 2014, 9:24:17 AM4/8/14
to commcar...@googlegroups.com
We've moved this discussion off users as it was getting very domain-specific.

Best,
Will


--
Reply all
Reply to author
Forward
0 new messages