Does that mean if cases are assigned to a location for example:
Then a mobile worker is assigned to both Location1 and Location2, will that mobile worker be able to access all the cases assigned to those locations (Case1, Case2, Case3, Case4) or only the cases at their Primary location?
I just tested it out, and I believe the behavior is this:
Users will only receive cases owned by locations whose level is tagged "Owns Cases", and they'll receive all such cases if assigned multiple locations.
However, if your user is in multiple case sharing locations, then you might see an error in registration forms that says
The case sharing settings for your user are incorrect. This user must be in exactly one case sharing group. Please contact your supervisor.
You can resolve this by creating a hidden value in your registration form with the calculate expression instance('commcaresession')/session/user/data/commcare_location_id
And then save this to the case property owner_id. That'll tell CommCare to use the user's primary location as the case owner.
if you want to have a little more control over that, you can populate a lookup table question with the locations that the user has access to and have them select one to update the owner_id.
it's a little funny and DANGEROUS because the app doesn't care what you put in there. it will stop throwing that "belongs to more than one case sharing group" error as soon as it sees that you are updating owner_id. so there is a significant room here to destroy your case and becoming unable to see it anywhere.
Additionally, if you have a "view child locations" option ticked on a parent location to the one the mobile worker is in or has access to, you'll also see that the form will load the lineage tree into the "locations" meta. can be confusing - the level to expand to and from settings in the advanced options
it is important to note also that this error will only show up in forms that create cases. So unless the user that has multiple location access needs to create cases, you don't need to worry about it.
Thank you for that extra information @Mazz. That's really helpful actually. I havent had time to get to a proof of concept yet, but the idea is to have an organization structure to control the location hierarchy. For example:
FDP (Food Distribution Point)
Cases would then have their owner_id set to the FDP id. So in essence cases would belong to a FDP location. I have done this before in a previous project and it worked well, however in that scenario a mobile worker only needed to see cases from 1 FDP location. I am now looking at a project where a mobile worker needs to be assigned to multiple FDP locations and not necessarily a District location directly above it as a parent. So its really helpful to know that I will be able to achieve this.
This actually leads me to my next question, as we dont intend the mobile workers to create the cases via the mobile app at all, but rather we would be creating the cases from a .net webapp via the API.
I have created a separate thread for that though here: