How to filter a case list to display only cases that the mobile user’s location owns

commcare

My application has a parent case with 3 child cases. Locations own cases, but sometimes the location only owns the parent case and one child case. How can I filter the parent menu so that no parent cases appear if the location doesn't own this parent case (i.e. the location owns a different child case)?

Best Answer

I was able to get this to work by filtering the parent menu with the following filter:

@owner_id=instance('commcaresession')/session/user/data/commcare_location_id

This filter only shows cases when the case's location owner_id is equal to the current mobile user's location ID.