In Action: Link a Results Page to a Results Page
In one-to-many relationships it is sometimes necessary to link directly between a single record in a results page and all associated records in another results page. This article shows you how you can use a hyperlink and an AutoNumber parameter to link to between a single record in one results page and another results page displaying all associated records from a second table.
Some examples where results to results links may be useful:
- Link to all log entries associated with a specific record (support ticket action logs, customer contact records, etc.)
- View all user records associated with a specific event record (attendees, signups, etc.)
The example used in this article shows a searchable listing of club members. Each club has multiple members. Clicking on the “Members” link for each club record will display another Report DataPage listing all of the members in that club.
There are two tables used in this example:
These tables are associated using the Club_ID field. The Club_ID is the primary key of the Clubs table and is a foreign key in the Students table. It is a one-to-many relationship because one club may have many students. For simplicity, each student can only belong to one club.
Now that we have our base tables we can start to create our DataPages.
Steps to link a results page to a results page:
Create the Club Report DataPage
We are going to start by creating a searchable Report based on the Clubs table. In the DataPages view of Caspio Bridge click on the New button to open the DataPage Wizard. This Report can be created as normal. Be sure to enable advanced options and parameters. Choose the Clubs table as your data source and provide whatever search functionality, results display, and details fields you would like.
When you come to the Configure Results Page Fields screen, insert an HTML block using the Insert button at the lower right of the DataPage Element panel. This HTML block is going to hold the link to the Student Members Report. For now just type “Members” in the HTML Block panel as a place holder for the future link.
Finish creating the Report DataPage and preview inside of Caspio Bridge.
Create the Student Report DataPage
Now we are going to create the Student Members Report. This Report is different from the previous Clubs Report because it will not have a search page. Click the New button to open the DataPage Wizard again.
Select the Students table as your data source and enable both advanced options and parameters. On the Search Types screen select the radio button marked Filter data based on your pre-defined criteria. Also click the checkbox to allow parameters in search criteria and select the radio button for both Bridge and external parameters.
These steps allow us to pass the club ID from the Clubs Report and use it as the search parameter here to filter the Students Report. In the Select Filtering Fields screen include the club ID as the filtering field by moving it to the right-hand panel. Click Next. The following screen is the Configure Filtering Fields screen. Select the club ID field and click on the advanced tab. Here, select the Radio button to receive a parameter.
Be sure to note the parameter name (in this case “Club_ID”), the parameter name in the Club Report must match this parameter name exactly.
You can configure the rest of the Report however you would like. Click Finish when complete.
Linking the two Report DataPages
Now that the DataPages are complete we can link them together by changing the placeholder members link text from earlier into a hyperlink to the Student Members Report. First we need the URL of the Students Member Report. To get a location we will deploy the DataPage.
For this example we are going to use the Direct from Caspio method to deploy our DataPages. You can use this same technique with the embedded method. Just use the URLs of your host pages instead of the Direct from Caspio URLs.
Click on Deploy and, from the method dropdown, select Direct from Caspio. Select the Link Radio button. Copy the deploy code and click Finish.
Now open the DataPage wizard again by selecting the Clubs Report and pressing Edit. If you haven’t already, make sure that both advanced options and parameters are enabled in this DataPage.
Proceed to the Configure Results Page Fields screen. Select the HTML block that contains your member’s link placeholder. Paste in the deploy code link from the Students Report. If you are using the Direct from Caspio method, the default link text will be the DataPage name. Update the hyperlink text to say “Members”.
Finally, we are going to pass the club ID as a parameter. Because we are using the Direct from Caspio deployment method, we are going to use an and symbol (&) to create a query string instead of a question mark. With the Direct from Caspio deployment, the first query string is always the AppKey of your DataPage.
After the AppKey (the long series of numbers and letters) add an and symbol (&). Write Club_ID (make sure it is spelled the same as the receiving parameter in the student Report DataPage. Now add an equal sign. Then, using the Parameter Insert button at the lower right hand of the HTML panel, insert the Club_ID parameter in string format.
If you are using the embedded method and the club ID is your first parameter, use a question mark (?) as your query string signifier.
Click Finish when complete.
Now your two DataPages should be connected. You can test the link right inside of Caspio Bridge.