How can I use custom location data on form display logic.
You can find example references for custom location data at this wiki page, 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”)?
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?
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.
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
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.”
Can you double check the quotation marks in the expression? Form builder accepts
", but will throw that error if you use
“. Unfortunately, a lot of rich text editors like Microsoft Word or this forum software convert to the second set of quotes automatically.