cfreportparam

Description

The cfreportparam tag lets you perform the following tasks:

  • Pass input parameters to a ColdFusion Report Builder report definition.

  • Override query data in subreports and charts defined in Report Builder reports.

  • Override styles defined in Report Builder subreports.

The cfreportparam tag is always a child tag of the cfreport tag.

Syntax

<cfreport template = ...> 
    <cfreportparam 
        chart = "name of the chart contained in the report or subreport" 
        name = "data name" 
        query = "query value passed to the chart or subreport" 
        series = "ordinal number of a chart series" 
        style = "CSS style definition or CSS file pathname" 
        subreport = "name of the subreport" 
        value = "data value"> 
</cfreport>
Note: You can specify this tag’s attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag’s attribute names as structure keys.

See also

cfreport; Creating Reports with Report Builder in the Developing ColdFusion Applications; Report Builder online Help

History

ColdFusion 8: Added the chart, query, series, subreport, and style attributes.

ColdFusion MX 7: Added this tag.

Attributes

Attribute

Req/Opt

Default

Description

chart

Optional

 

Name of the chart contained in a report or subreport. The value of this attribute must match Name property of a chart defined in the Report Builder report. If you specify the chart attribute, you cannot specify the subreport or name attribute.

name

Optional

 

Variable name for data that is passed. The value of this attribute must match the name of an input parameter defined in the Report Builder report. If you specify the name attribute, you cannot specify the chart or subreport attribute.

query

Optional

 

Query value to pass to a subreport or chart. The ColdFusion query must contain at least all of the columns included in the Report Builder query. Charts and subreports require this attribute.

series

Optional

1

Ordinal number of a chart series to use for the query. This attribute is valid only when the chart attribute is specified.

subreport

Optional

 

Name of the subreport. The value of this attribute must match the Name property of the subreport in Report Builder. Subreport names within a report must be unique. If you specify the subreport attribute, you cannot specify the chart or name attribute.

style

Optional

 

Style in CSS format for a subreport. The value can be an absolute file path, a file path relative to the report, or a string in valid CSS format. For the styles to take effect, the style names must match Style Name attributes assigned to elements in the Report Builder report. You can generate the CSS file in Report Builder and exported or created with a text editor. For a list of supported CSS styles, see the section Style properties.

value

Optional (see Description)

 

Value of the data that is sent. Specify the value attribute with the name attribute. You cannot specify this attribute when a chart or subreport attribute is specified. The value can be a string or a variable.

Usage

You can specify only one of the following attributes in a cfreportparam tag:

  • name

  • subreport

  • chart

You can use the query, subreport, and chart attributes to override Report Builder queries and chart information at run time. This way you can customize subreport and chart data from the CFM page without having to change the queries built into your report.

For example, in Report Builder, you can create a master report that contains several subreports and populate each subreport with a different query. Instead of modifying the queries in Report Builder, you can customize your reports by creating modified queries on the ColdFusion calling page. The ColdFusion query must contain at least all of the columns included in the Report Builder query.

Note: You cannot specify a subreport query that depends on arguments from the master report. Instead, you can define a CFML function or CFC method that returns the subreport query given the arguments from the master report. ColdFusion calls this code when it executes the subreport.

On the calling CFM page, you can specify a cfreportparam tag for any subreport and chart in the Report Builder report. The value of the subreport or chart attribute must match the Name property of the subreport or chart defined in the Report Builder report. (Charts are treated like subreports.)

The following code shows a master report that contains two subreports and a chart with two chart series:

<cfreport template="myreport.cfr" query="master" format="RTF"> 
    <cfreportParam subreport="subreport1" query="subquery1"> 
    <cfreportParam subreport="subreport2" query="subquery2"> 
    <cfreportParam chart="chart1" series="1" query="chartquery1"> 
    <cfreportParam chart="chart1" series="2" query="chartquery2"> 
    <cfreportParam name="ReportDate" value="#DateFormat(Now())#, #TimeFormat(Now())#"> 
</cfreport>

The cfreportparam tag also lets you override CSS styles assigned to subreports in Report Builder. Use the style attribute with the subreport attribute; the value of the subreport attribute must match the name of the subreport in Report Builder. The following code applies a style sheet to the master report and two different style sheets to the subreports:

<cfreport template="myreport.cfr" style="myStyle.css" format="PDF"> 
    <cfreportParam subreport="subreport1" style="subreport-style.css"> 
    <cfreportParam subreport="subreport2" style="subreport-style.css"> 
</cfreport>

For more information, see the section Using Cascading Style Sheets.

Example

<!--- The following example shows how to override a query in a Report Builder report from the CFM page. The cfreportparam tag adds the current date and time to the report.---> 
<cfquery name="coursedept" datasource="cfdocexamples"> 
    SELECT Departments.Dept_ID as dDept_ID, Departments.Dept_Name, 
     CourseList.Course_ID, CourseList.Dept_ID as cDept_ID, 
     CourseList.CorNumber, CourseList.CorName, 
     CourseList.CorLevel 
    FROM Departments, CourseList 
    WHERE Departments.Dept_ID = CourseList.Dept_ID 
    ORDER BY CourseList.Dept_ID 
</cfquery> 
 
<cfreport format="PDF" template="FourthReport.cfr" query="#coursedept#" overwrite="yes"> 
<cfreportparam name="ReportTime" value="#DateFormat(Now())#, #TimeFormat(Now())#"> 
</cfreport>