Creating a Details Page for a Single Record
This tutorial will show the process for writing a page to display any details for a specific database record. Typically, a summary report would like to these pages. For this example, we'll use the page's title to determine which row to query in the database.
Step 1: Query the row based on the page title
To do this, insert an SQL Variable macro to query the row into a variable. The parameters should be:
- Name: name the variable something appropriate based on the data you're reading
- Data Source: put the name of the data source you're querying
- Injected: make sure this is checked because we'll need to inject the page title
- Data Type: set this to "Row". This ensure the resulting data type of the macro represents just one result. This will make it easier to select data from the row later on.
In the body of the macro, put the query to select the individual row. We'll inject the page's title into the query as %content:title%
. For example:
select * from product where product_name = '%content:title%'
Step 2: Display data from the row
Using the Report Info macro
You can output individual data points from the row using the Report Info macro. This makes it easy to apply formatting or changing the render type. The key will be in the form variable:myVar > row:propertyName
. The variable name is the one you set in step 1 and the property name is the database column name or alias.
Example
The product's name is
Using the Report On macro
The Report On macro makes it easier to output multiple data points without needing multiple macros. Simply wrap it around the content and make sure to check the "Injected" option. Any formatting will need to be done using suppliers.
Step 3: Reuse
Once the page is working, try moving the code to a template and reusing it as a Live Template