# Filter Case List by Owner\_Id

**URL:** <https://forum.dimagi.com/t/filter-case-list-by-owner-id/4913>\
**Category:** Users\
**Created:** [January 23, 2018, 5:59pm UTC](https://forum.dimagi.com/t/filter-case-list-by-owner-id/4913 "2018-01-23T17:59:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![natalieflp](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/n/b5ac83/32.png) [@natalieflp](https://forum.dimagi.com/u/natalieflp)\
**Post date:** [January 23, 2018, 5:59pm UTC](https://forum.dimagi.com/t/filter-case-list-by-owner-id/4913/1 "2018-01-23T17:59:43Z")

</div>

I have case sharing based on location set up in my app, so there is a question called owner\_id in my registration form which is set when the user selects the location as the answer. Owner\_id is then saved as a case property. I wanted to have one case list filtered by a specific owner\_id/location, but when I entered "owner\_id='c9d769ae69e0476b91aa376becce69df'", the list is not filtered (I can still see every case even if the owner id is not equal to the above). I tried the id with single quotes, double quotes and without quotes, I tried using the location name, and the location site code, but nothing filters the list.

Is it possible to filter a case list by an owner\_id?

---

<div class="post-metadata">

**Author:** ![Clayton\_Sims](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/clayton_sims/32/496_2.png) [@Clayton\_Sims](https://forum.dimagi.com/u/Clayton_Sims)\
**Post date:** [January 23, 2018, 7:03pm UTC](https://forum.dimagi.com/t/filter-case-list-by-owner-id/4913/2 "2018-01-23T19:03:55Z")

</div>

Hi Natalie,

It is possible to filter by owner id, apologies for the confusion and lack  
of clarity on this point.

There are a couple of case properties (_case\_id_, _case\_type_, _owner\_id_,  
and _status_) which are represented differently internally, in order to  
reference them in case list filters, they must be preceeded by an _@_ sign.

In your case you would reference the owner id in the filter as

@owner\_id=‘c9d769ae69e0476b91aa376becce69df

As a very technical explanation you can find the XML document structure of  
the case database on the device on our wiki, which will provide clarity  
into how these references function if you are familiar with XML/XPath,  
which is the foundation of our data model/query structure

> **[casedb](https://github.com/dimagi/commcare-core/wiki/casedb)**
>
> Core Java engine for CommCare, the world's largest platform for designing, managing, and deploying robust Offline First mobile applications to frontline workers worldwide - dimagi/commcare-core

-Clayton

---

<div class="post-metadata">

**Author:** ![natalieflp](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/n/b5ac83/32.png) [@natalieflp](https://forum.dimagi.com/u/natalieflp)\
**Post date:** [July 31, 2018, 11:27pm UTC](https://forum.dimagi.com/t/filter-case-list-by-owner-id/4913/3 "2018-07-31T23:27:17Z")

</div>

Hi Clayton,  
Follow up question: are you able to filter case list by properties of the owner? So instead of filtering by the current session's user properties, I would want to sort by the owners user properties.

Thanks!

---

<div class="post-metadata">

**Author:** ![Clayton\_Sims](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/clayton_sims/32/496_2.png) [@Clayton\_Sims](https://forum.dimagi.com/u/Clayton_Sims)\
**Post date:** [August 3, 2018, 8:31pm UTC](https://forum.dimagi.com/t/filter-case-list-by-owner-id/4913/4 "2018-08-03T20:31:23Z")

</div>

Hi Natalie,

Unfortunately this is quite difficult when cases are owned by users, as user data models aren't distributed to all devices.

To accomplish the use case you are referring to, you'll need to use the [Organizations (or 'Locaitons')](https://confluence.dimagi.com/display/commcarepublic/Organizations) feature to assign and distribute metadata to the "location", which would also be the owner of the case. This feature allows you to control what subset of location data is sent to the phones, since otherwise, the devices could end up with more data than they could handle.

-Clayton
