This article will discuss using page rules to show a message when a date/time is approaching.
Scenario
Your app contains records from your database that have a specific date/time. You want users to be notified of an upcoming event.
Example:
A project management app displays a list of upcoming milestones. Your app will display a message to your employee when a deadline is approaching.
Recipe
This recipe will use page rules to show a warning message based on a date/time value. You will need an object that has a date/time field in order to add a page rule to create the message.
Create a Details View for a Deadline
In the Pages section of the builder, select the page that contains your project deadline.
Create a Page that will Display Your Message
Navigate to the Pages tab in the Builder. You will want to create a details page, that will contain a view with the date/time record.
Create a Project Details View
After you have created a page, you will want to add a details view that will display information about the Project. Once you’ve selected this page, click to add a details view:
You will be prompted to choose what records this details view will display. Select the object that contains your date/time field. In this example, it is Project:
Your page will now contain the project details view:
Add a Page Rule to Display a Message based on a Date/Time Field
Where to Add a Page Rule
From your project details page, navigate to the Rules tab and click “Add rule”:
Properties for Page Rules
After you click “Add rule”, several properties will appear for you to fill in. This is where you tell your live app what to display, based on a record value.
The page rule should have the following properties:
-
When: Start date is during the next 7 days
-
Action: Show a message
-
Message: Set type to Warning. Add a custom message.
See your Message in your Live App
To view your message in action in your Live App, navigate to the details page where you have set your page rule. If the start date of this record is during the next 7 days, your message should appear at the top of your details view:
Optional Features
You can add additional rules to your project details, to display different messages based on the how soon the deadline is.
Click the green “+” button to add an additional rule, and define the parameters to reflect the behavior you would like in this rule.
In our example, we can add a red alert message that contains bold formatted text, which will appear when the start date is set to today. We can also check a box that allows the user to close or ignore the message.
In your Live App, you will see that if the start date is today, your red alert message should appear at the top of your details view:
Find out more about how Page Rules can enhance your app's functionality.