Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

For users already familiar with CommCare's conditional select functionality, referencing locations within a form is very similar.  To access the list of locations from within a CommTrack form, you can use the syntax described HERE.

Much like lookup tables in order to reference location data in a form, you must first include a reference to this instance in the forms xml.  To access this xml, enter your form, and in the top righthand corner, under "Tools", select "Edit Source XML"

You'll need to add the following line to the instances in order to reference location data:

<instance id="locations" src="jr://fixture/commtrack:locations"></instance>

Place this just above the first "<instance>" here:

 

Next you'll need to add a select question to the XML.

It should look something like: 

<select1 ref="/data/state">
<label ref="jr:itext('state-label')" />
<itemset nodeset="instance('locations')/states/state">
<label ref="name"/>
<value ref="id" />
</itemset>
</select1>

You can drill down to any level of location within this hierarchy by following this model.  For example, if your hierarchy starts at the regional level, then proceeds to state, then district, then facility.  You can reference facilities like this:

<select1 ref="/data/outlet">
<label ref="jr:itext('outlet-label')" />
<itemset nodeset="instance('locations')/states/state/districts/district/outlets/outlet">
<label ref="name"/>
<value ref="id" />
</itemset>
</select1>
  • No labels