...
<instance id="locations" src="jr://fixture/commtrack:locations"></instance>
Place this just above the first "<instance>" here:
...
Note that whenever referencing the location hierarchy, only locations with which a mobile user is associated will sync to that users phone. So, if the mobile user account is linked to outlet 'a', then the only district that will appear on that users phone is the district to which outlet 'a' belongs, and the only state will be the state to which that district belongs.
UPDATE !
In order to set up a single of multiple answer questions on locations, follow these steps:
- Add a Single/Multiple Answer Lookup Table:
- Click on the "Lookup Table Data" question
- Edit the following fields:
- Lookup Table: ignore that for now
- Value Field: what you want to save as an answer (usually an id or a code). For locations you can use site_code or @id.
- Label Field: what you want to display to the user. For locations you can use name
- (Optional) Filter: can be used to filter the locations displayed.
- The tricky part is now to modify the xml to point the question to the location table. To do so:
- Click on Tools / Edit Source XML on the top right corner of the form builder:
- In the XML search for a select1 node holding your lookup question. It should look like this:
In this example my lookup question is /data/location_loookup - Then in the expression <itemset nodeset="instance('products')/products/product">, replace the instance with the instance of your location. For example
- if you want to display the list of states: instance('locations')/states/state
- if you want to select the list of
- Click on Tools / Edit Source XML on the top right corner of the form builder: