Introduction
Conditions appear in many places in Glide and are used in different ways. You can use Conditions to do things like:
- Show all the items with
status
marked ascompleted
- Hide a component if the user is not an admin
- Notify your team in Slack if an order is bigger than $10K
- Show the delete button only if a user has the right priveledges
Because conditions can appear in so many places, this is quite long. You are unlikely to need all of it. Here's an outline of the main sections.
- Filtering lets you filter out records from your collections. If you don't want everything in your data source to show, you'll need this.
- Visibility lets you hide tabs and components. If there are certain screens or functionality that you don't want users to have access to, you should check this out.
- You can also create conditions that affect who or when people can add and edit data
- This section will explain in more detail the types of values you can use in your conditions.
Filtering & Visibility conditions are NOT security features. When you hide tabs, components, or filter out items in lists, the data is still accessible on your device. Read our Security Guide to learn how to protect sensitive data.
Filtering
Filtering a collection
By default, Collections show all the rows coming from your data source. However, you can filter the rows that appear. To filter items out of a list or collection, visit the component's options panel.
Filtering Items of a List
To set a filter, click Add Filter. A new filter will be added by default.
In the app below we've added a filter that shows only the employees where the Is Manager column contains 'Yes'.
Filtering
You can use the same table as a source in multiple tabs and then filter each one in different ways. For example, the app below shows the same staff list in three different tabs. Each tab has the same exact source table, but each one is filtered to show only those with a different diet.
Different Tabs With Different Filters With The Same Data Table
Multiple filters
You can use multiple filters on a list with AND + OR logic. In the following example, we have added two filters to the list of cookies to show only items that include 'coconut' or 'coffee' in the Name
column.
Adding Filters With And Or
Custom vs Column Values
You'll notice that in all the previous examples we entered custom values in the final part of the condition. But if you click the three dots in that field, you'll have access to column values, user-profile values and potentially even more.
To learn more about the types of values, checkout the values section of this library.
Visibility
Tab Visibility
You can hide and show different tabs based on User Profile data.
To do this, you can add conditions in the Options section of each tab. For example, in the app below, the Reports tab will only show users who have the role of Admin
.
Component Visibility
To set a condition on a component's visibility, head to the Options tab in the component's settings. There you will be able to add a condition based on the data in your table. Once you add this condition, the component may disappear from the app's screen, but you can still access it on the left-hand side of Glide.
In the image below, the button component is only shown if the User's role is Admin.
Component Visibility
You can use Containers to control the visibility of multiple components at the same time. Learn more here.
Conditional add, edit & delete
Allowing users to add, edit & delete records can be very powerful, but you'll almost certainly want to restrict this to only certain items or to certain users.
To apply conditions to a collection, click on the Collection component and go to the 'Actions' tab in its settings. You can enable or disable add/edit/delete, as well as adding conditions beneath each one.
You could set conditions like:
- Only allow adding items if the total number of items is below 100
- Only allow a user to add items if they are an Admin
- Only allow users to add items if they have completed their user profile
What values do I have access to in conditions?
When adding conditions, the final field gives you the option to add either a custom value or a column value. Depending on the context and your app's settings, you may have access to different types of values.
Current Row
The default list of columns will show you the data for the current row. This is the most common type of value you'll see in this menu.
For example, in the image below we're adding a condition on a button on an employee's details screen. The data tab at the bottom shows the data for the current record and you can see that these correspond with the column values we have access to in our condition.
Current Row Columns
User Profile
If you've configured a User Profile table for your project, the data related to the currently logged in user is available to use for conditions.
You can use this in lots of ways, but particularly when hiding tabs. When you set conditions on a tab's visibility, you only have access to User Profile values.
Containing Screen Context
When you are creating conditions, you may see another category called 'Screen'.
Using Screen Condition
This lets you choose values from the current screen – enabling you to do things like:
- Show items where Category is the same as Category (to show a list of items that relate to this one)
- Show items where Price is equal to Price (to show a list of items which have the same price as the current item)