Reports created using the ColdFusion Report Builder are more report templates than actual reports. They are designed to allow you define the presentation of report data, data that may not even exist until report execution time. For example, although a SQL query could be embedded in the report as the default query, it can be overridden at runtime by passing an alternate query to cfreport. Similarly, name=value pairs may be passed to cfreport and these may be used as display fields or as parts of a CFML expression.
One of the more intriguing Report Builder properties is the Print When property. Just about any field or object (including embedded charts and sub-reports) have a Print When property. This property is usually empty, and so the item will always be included in the report, but you may provide an expression so as to conditionally include items. For example, suppose you had a chart in your report, and you wanted to allow the user at runtime to specify whether or not the chart is to be generated. To do this you’d define a report input parameter (perhaps named ShowChart with a default value of 1), and you’d set the chart Print When property to params.ShowChart. This way the chart will be generated when the ShowChart parameter is true (the default), but not when it is false. Then at runtime you could simply pass ShowChart as an attribute to cfreport (or cfreportparam) specifying true or false as needed, thereby overriding the params.ShowChart default value, and thus conditionally including or excluding the chart.
This type of flexibility allows developers to construct highly dynamic reports that can be adapted as needed at runtime.
Leave a Reply