# How can I use custom location data on form display logic

**URL:** <https://forum.dimagi.com/t/how-can-i-use-custom-location-data-on-form-display-logic/6478>\
**Category:** Developers\
**Created:** [May 16, 2019, 12:51pm UTC](https://forum.dimagi.com/t/how-can-i-use-custom-location-data-on-form-display-logic/6478 "2019-05-16T12:51:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyasne](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/andyasne/32/2626_2.png) [@andyasne](https://forum.dimagi.com/u/andyasne)\
**Post date:** [May 16, 2019, 12:51pm UTC](https://forum.dimagi.com/t/how-can-i-use-custom-location-data-on-form-display-logic/6478/1 "2019-05-16T12:51:20Z")

</div>

How can I use custom location data on form display logic.

---

<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:** [May 16, 2019, 3:19pm UTC](https://forum.dimagi.com/t/how-can-i-use-custom-location-data-on-form-display-logic/6478/2 "2019-05-16T15:19:05Z")

</div>

Hi Andinet,

You can find example references for custom location data [at this wiki page](https://confluence.dimagi.com/pages/viewpage.action?pageId=38276915), I think specifically this is the reference style you will need:

instance('locations')/locations/location[@id = instance('commcaresession')/session/user/data/commcare\_location\_id]/location\_data/ **custom\_field\_id**

Are you facing errors when trying to use such references (like "instance is not available")?

-Clayton

---

<div class="post-metadata">

**Author:** ![andyasne](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/andyasne/32/2626_2.png) [@andyasne](https://forum.dimagi.com/u/andyasne)\
**Post date:** [May 18, 2019, 9:10am UTC](https://forum.dimagi.com/t/how-can-i-use-custom-location-data-on-form-display-logic/6478/3 "2019-05-18T09:10:23Z")

</div>

yes, am facing that problem. do I have to reference a location on every form to implement this? won`t this affect over all speed of the app?

---

<div class="post-metadata">

**Author:** ![Ethan\_Soergel](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/ethan_soergel/32/543_2.png) [@Ethan\_Soergel](https://forum.dimagi.com/u/Ethan_Soergel)\
**Post date:** [May 20, 2019, 2:17pm UTC](https://forum.dimagi.com/t/how-can-i-use-custom-location-data-on-form-display-logic/6478/4 "2019-05-20T14:17:01Z")

</div>

Hi Andinet,

Does the expression Clayton shared above not work? Specifically, I'd try this, substituting out the appropriate field name and value:

`instance('locations')/locations/location[@id=instance('commcaresession')/session/user/data/commcare_location_id]/location_data/FIELD_NAME = 'FIELD_VALUE'`

I tried that out just now on my project space, and it worked as expected. Could you share the expression you're using and the complete error message?

> do I have to reference a location on every form to implement this? won`t this affect over all speed of the app?

I wouldn't be concerned about the speed of your app, although you could of course try it with and without the display conditions to be sure. You will need to put this condition on every form you'd like to hide, although if there are whole menus that use the same display logic, you can put the display condition on the menu instead.

---

<div class="post-metadata">

**Author:** ![andyasne](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/andyasne/32/2626_2.png) [@andyasne](https://forum.dimagi.com/u/andyasne)\
**Post date:** [May 21, 2019, 9:12am UTC](https://forum.dimagi.com/t/how-can-i-use-custom-location-data-on-form-display-logic/6478/5 "2019-05-21T09:12:35Z")

</div>

HI Ethan,  
the xpath you wrote do work if I referenced a location on the form.  
but I tried This and it is returning the following error  
if(count(instance(‘locations’)/locations/location[@id=instance(‘commcaresession’)/session/user/data/commcare\_location\_id]/location\_data/Workflow\_RMNCH)\>0,  
instance(‘locations’)/locations/location[@case\_id=instance(‘commcaresession’)/session/user/data/commcare\_location\_id]/location\_data/Workflow\_RMNCH, “Off”) = “On”

The error is "There is something wrong with the logic in the Form Display Condition. Check to make sure your parentheses match and you are referencing case properties correctly."

![err](https://dimagi.b-cdn.net/images/transparent.png)

---

<div class="post-metadata">

**Author:** ![Ethan\_Soergel](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/ethan_soergel/32/543_2.png) [@Ethan\_Soergel](https://forum.dimagi.com/u/Ethan_Soergel)\
**Post date:** [May 21, 2019, 8:21pm UTC](https://forum.dimagi.com/t/how-can-i-use-custom-location-data-on-form-display-logic/6478/6 "2019-05-21T20:21:01Z")

</div>

Can you double check the quotation marks in the expression? Form builder accepts `'` and `"`, but will throw that error if you use `’`, `‘`, `”`, or `“`. Unfortunately, a lot of rich text editors like Microsoft Word or this forum software convert to the second set of quotes automatically.
