In Action: Display a Personalized Message to Your Users
This article shows you step-by-step how to add a customized message based on the current logged-in user. In order for this message to be created, your DataPage must be authenticated. We will be using parameters to pull information from the authentication table to display it directly to the end-user. This technique can be used for any field in your authentication table, and on any authenticated DataPage.
In this example we are pulling the first name of the logged-in user and displaying a custom greeting to that user.
Steps to adding a personalized message:
1. Note the exact fieldname(s) you’d like to reference
Open the authentication table or view that was used to password protect your DataPage. Locate the field(s) you want to reference in your message. Copy their fieldnames for future reference. In this example we are going to pull the First_Name field.
2. Enable Parameters
Be sure to enable parameters on the first page of the DataPage wizard.
3. Add a header & footer
You can add parameters into any portion of a DataPage including header and footers, HTML blocks, labels, etc. In this example we are going to add a greeting into the header section. First, proceed to a Configure Fields screen in the wizard. Web Forms have only one Configure Fields screen, but Search and Report Pages have three (search, results and details pages). Press the Insert button at the lower right corner of the DataPage Elements panel. Choose Header & Footer to insert these sections.
4. Construct your authenticated parameter
Inside the header section we are going to type out a parameter. We can pull data directly from the authentication table (or view) by creating a parameter using the following format:
It is important that “authfield:” is included before the fieldname. This tells the DataPage to pull the data from the authentication table (or view) and not from the base table. In this example the parameter would be [@authfield:First_Name].
5. Write a message using the new parameter
In this example we are pulling the first name data to say, “Hi, John! Here are today's Inquiries:” (John will be replaced dynamically with the first name of the current logged-in user). We’ve also added some HTML formatting. Press Finish to save the DataPage.
6. Preview and adjust
Preview your message either directly in Caspio Bridge or on your webpage to verify formatting and placement are as expected.
- Are parameters enabled in the DataPage?
- Is the parameter formatted correctly. Here's the correct format: [@authfield:xxxxx]
- Does the authentication table or view have data in that field?
Personalized messages are an impressive piece of polish to add to your apps. This is one example of how to use parameters to customize your DataPages. If you were able to create a personalized message, you may want to take a look at some of the other things that can be accomplished using parameters. Read more About Parameters.