Table of Contents

Page Rules

Lesley Updated by Lesley

What are Page Rules?

Page rules are actions that can be automatically triggered based on conditions you define as soon as a user enters a page.

For example, let's say your users can register for a specific event with limited availability. A page rule can be defined to hide the registration form when availability reaches zero.

Here are a few other examples of how you could use page rules:

  • Hide a form to edit a record if the user role of the logged-in user is not an “Editor”.
  • Hide a form to register for a class if the class attendance has exceeded a specific size.
  • Redirect to a registration form if the logged-in user hasn’t registered.
  • Warn the user if they need to update their data or complete some information.

Page rules are eligible to be added to child pages, or a start page with user logins enabled. Page rules cannot be triggered from values in multi-record views such as grids, lists, maps, calendars, etc.

Manage Page Rules

Add a Page Rule

You can access Page Rules in the Builder by clicking on the down arrow menu option next to the page’s name and select the option from the dropdown menu. This will open the page rules settings in the toolbox to the left. There you can add a new rule by selecting "Add Rule".

Edit a Page Rule

Existing page rules can be accessed and edited at any time from the same arrow down menu option when viewing a page. When editing a page rule any criteria can be added or removed with the " + “ or “ - " icons.

You can drag/drop each individual rule using the left anchor bar to keep your rules organized. You must press the "Save Changes" button in order for your changes to take effect.

Delete a Page Rule

To get rid of a page rule entirely, use the trashcan delete icon to the right of the rule panel. You must press the "Save Changes" button in order to save your changes permanently.

Build Page Rules

Define the Criteria

Page rules are triggered when specific criteria you define are true when a page loads. This criteria is added under the section titled "When the following criteria is true".

To set your criteria you select a specific field then define the criteria for that field. For example, when a status field in overdue, perhaps you want to display a message. In this case the criteria would need to check if the status field is set to overdue in order to trigger the rule.

The fields available to use will depend on the page. Child pages will let you choose fields from the table that page is based on or a connected table's fields. If the page is protected by a login, you will also be able to use fields from the account table and other user roles associated with that page's login.

In other words, fields from the source table of the page as well as fields from the user roles that have access to the page will be available to use in your page rules. If no fields are available, the "Rules" link will not be available.

You need to check for at least one criteria, but you can add as many as you need in a single rule. If you have multiple fields selected, they must all be true in order for the rule to trigger.

Define the Action

Each rule can only perform one action. This is added in the section titled "Run the following action". Select the action that you want your page rule to perform.

There are four main actions a page rule can perform:

  • Hide views
  • Show a message
  • Redirect to an existing page in your app
  • Redirect to another website URL
Hide Views

This action will hide any selected views when your criteria matches.

Show a Message

The show a message option will display a message of your choice. The message will be displayed at the top of the page, above any views.

There are 4 different message styles available; they each have a unique background color for different effects: "Neutral", "Confirmation", "Warning", and "Red Alert".

You can choose whether the message can be dismissed by the user or not. If toggled, an "X" icon on the top-right corner of the message will be displayed.

Redirect to the parent page

Once set, the user will be redirected back to the page that the child page originates from (otherwise referred to as the parent page).

This action is only available for child pages.
Redirect to an existing page

This action will redirect the user to a specific page within your app of your choosing. All starting pages are available as well as any other child page that has the same table as a source. If the child page is meant to display a specific record, the same record as the current page will be used.

Redirect to Another Website URL

With this action you add an external website URL to redirect your users to.

There are no "back" crumbtrail links generated when this option is selected, so if you’re linking to an external website, the only way back is by using the browser.

How Multiple Rules Work

It’s important to note that when you have multiple rules, all matching rules will be triggered at the same time. This is also true for rules that happen to have the same criteria. Knack will not stop triggering rules after the first rule matches.

Take the following scenario for example:

There are two page rules that will trigger when the Customer’s User Status is Active. The first rule will hide a view and the second rule will display a message. In this scenario, both rules will trigger, so the user will see a message and the view will be hidden as well.

Tweaking that scenario, the second rule will now redirect the user instead:

Technically both rules are still going to trigger, but since the user is being redirected out of the page they are never going to see the first message.

How-To Guides

The following is a step-by-step guide to creating a registration form with limited availability and using page rules to hide that form and display a message when availability reaches zero.

Create a registration with limited availability.

Notes & Troubleshooting

  • If you have multiple fields selected, they must all be true in order for the rule to trigger.
  • Page rules run before views on the page are rendered in the Live App. That allows for re-directs to be put in motion or only "show" views to be displayed.

How did we do?

Printing Pages & PDFs