client portals

Filter data per user

Updated: October 12, 2020

When you add a database connection to your portal, you do not have give all users access to all of your data. You can filter data on a per user basis (so users only see what you want them to see).

How filters work

A database connection filter consists of three elements:

  1. A column from your database table
  2. An operator
  3. A value

When a filter is applied to your database, it will return all the rows that match the filter's criteria.

For example, this is a filter that returns all the rows from a database where the column 'Client name' equals "Thomas Officer":

Does this 3 dropdown interface look familiar? It's the Expression Editor, the same mechanism you use to create conditional logic.

What value should you filter data with? 

This is the essential question to creating a database connection filter. In most cases, you will want Portal users to see their data and only their data. For this, the best approach is the use the `Portal Client ID` which you can read about below.

There are two ways to filter database connection data: (1) a generic filter that applies to everyone who joins your Portal; and (2) an individual filter that applies only to a specific user.

Generic filters

A generic filter applies to everyone who joins your portal. This is the most common type of filter and it's quite powerful.

You add a generic filter on the portal configuration page after you click "View permissions" for your database connection: 

Individual filters

An individual filter only applies to a specific portal user. This is not a very common type of filter.

You apply an individual filter either when you manually add a user or after a user has joined your portal. In either case, you use the Edit Client modal to apply an individual filter: 

Portal Client IDs

Every portal user has a unique `Portal Client ID`. You can use the Portal Client ID to filter your database connection data so that a user sees their data and only their data in your portal.

Let's assume you've already made an app and that this app includes a 'send data' function on one of its blocks such that it creates rows inside your database. You want to add this app to your portal and you want to add a database connection so that portal users can view their own data. Here is how you can create a database connection filter with`Portal Clients IDs` that does exactly that:

Step 1. Create a new column in your database

This is the column you will reference in your database connection filter. This column will contain the `Portal Client ID`, so you might as well label it "Portal Client ID."

Step 2. Have your app send `Portal Client ID` to this column

Go to the 'send data' function inside your app. Add a param for the new "Portal Client ID" column you added to your database then select 'Portal Client ID' as the value you want to send over: 

Step 3. Filter your database connection using `Portal Client ID`

This will be a simple filter with what looks like only two parts: 

  1. The column "Portal Client ID"
  2. Equals `Portal Client ID`

Now, Portal users who run this app (and thereby generate rows of data) will only see their data in your database connection.

Contact us for support

Talk to a real person, quickly. We're available 9am - 5pm EST.