Making select questions with locations as choices

Our project space has 6 organizational levels [Country -> Region -> Woreda -> HealthCenter -> HealthPost]. I would like to set up a Multiple choice question with the locations as choices. I’m trying to follow the instructions shown here: https://confluence.dimagi.com/pages/viewpage.action?pageId=38276915 under ‘Making select questions with locations as choices’. I want to display only the health centers that are found in a given 'Woreda'. But the app only displays a single health center as a choice while there are around six health centers in the location hierarchy.
The query expression i used is : instance('locations')/locations/location[@type = 'health-center' and @woreda_id = /data/location_name]

Hi Daki

So, this will show you all the location if the user you're currently using has access to all the locations.

if you wish to add a higher level than the one that the user you're using has, then you can go to the Oranization Levels ->Check the "advanced" checkbox

Then, find the level that the user you're currently using belongs to (or i should say, the location of that user) and then change the "level to expand from" and "level to expand to" options to match your needs and get that list of "6" locations. you should be using those location's levels to expand from.

but essentially, your user can't see all the locations because their location is at the bottom of the tree, or has no access to data from other locations.

HTH

Mazz

Hi Mazen,

Thank you very much for your reply. The user that i am using is at the last level(Health Post). And i have updated the “level to expand from” and “level to expand to” settings as per your recommendation but i still cant see all the Health Centers.
My worry is that the user might not have a permission to view other locations other than its own. Do you think there is a way to grant the user access to all the locations?

you might be right, but i think that's the reason the feature to change where a location expands from exists. so, unless i understood the feature wrong, this is exactly what it's for.

but one reason where it might not show you what you're looking for yet is that sometimes the user data doesn't take all the changes that it should when it comes to this kind of stuff.

so, i suggest you clear the user data from the emulator/mobile phone, and then sync on a clean database so that it grabs all the records it needs to grab from scratch. i feel that sometimes if the app already has data for something, when that data changes, it doesn't always get the update. this isn't case data, but only related to location and stuff that's affected by it.

give it a shot and let me know! if it doesn't work, maybe i can dig a little bit more

HTH

Mazz

Thanks again Mazz, I think its working for me now. Here is what i just did: I have changed the location of the user to the 4th level, which is (Zone). Then the app started to pull all the child locations(the Health Centers, in my case).

Best,

2 Likes