Menu Filtering

CommCare allows you to intelligently filter menus in your application based on standard XPath Expressions. This article walks through filtering menus, but filters can also be used on individual questions

Enabling Menu Filtering

  1. To enable menu filtering, you first need to enable the Display Conditions add-on. Select the gear icon next to the application name in the upper left hand corner. Then select the Add-Ons tab.





  2. Select the three lines on the right hand side and select the 'Calculations' option if it is not already displayed.





  3. Now enable the "Display Condition" add-on. Be sure to save after enabling the feature:


Creating a Menu Filter

Menu filters are added on the Menu Settings page:

Expressions are written using a standard XPath Expression. You can find examples of these on the Common Logic and Calculations and CommCare Functions.

Note that you must change your CommCare version to 2.20 or later in the Application Settings AND you must be using CommCare mobile 2.20 or later in order to use a Menu Filter.

Common Uses

Hide a menu from all users

You may want to temporarily hide a menu in a deployed version of an app. In order to do this you can simply use: "false()"

Hide a module from some users

Menu filters can reference Custom User Data, so you can create an XPath expression that registers a particular user property. For example if your users for which the user data type is supervisor you could create the following XPath expression:

count(#session/user/data/type) > 0 and (#session/user/data/type= 'supervisor')

Another example is when you want to use your app in several countries and only show specific content to users from each country. For example when deploying an app to India, Senegal, and Zamba, the user property country would be set to either India, Senegal, or Zambia for each user. If I want to show the module to users from only Senegal and Zambia I would create the following XPath expression:

count(#session/user/data/country) > 0 and (#session/user/data/country = 'Senegal' or #session/user/data/country= 'Zambia')