AdobeStock_455007340

Conditional CFMX7 Report Inclusions

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.

9 responses to “Conditional CFMX7 Report Inclusions”

  1. Dimitris Siskopoulos Avatar
    Dimitris Siskopoulos

    Can i use Report Builder with SQL Server 2000 Stored Procedures?

  2. Dimitris Siskopoulos Avatar
    Dimitris Siskopoulos

    I tryed to create an advanced query from Query Builder to call via CFML a Stored Procedure with the following code:
    <CFSTOREDPROC procedure="wl_srv_lst" datasource="etour">
    </CFSTOREDPROC>
    (no params needed)
    i have give a variable containing query object a name : myq
    Then i save it, added a field pl_text (this is one of the fields that the SP returns) in the Query Fields and added to my Detail in the report page, but i get a "Variable myq is undefined" message. Any help?

  3. Dimitris Siskopoulos Avatar
    Dimitris Siskopoulos

    As long as i’m "playing" with Colfusion Report Builder, i’m loving it more and more…
    Cool features, great GUI and simple interface … my cons to it’s developers.

  4. Ed Eelch Avatar
    Ed Eelch

    I have a query that will need a page break and it only returns one record…but it is long..how can I create more than one page…I would like to insert page breaks and make the page prop…50in long…any ideas.???

  5. Brett Liotta Avatar
    Brett Liotta

    I’m having the same problem Ed. Can’t seem to figure out how to add a "manual page break". I don’t think it’s possible yet. maybe the next version of the report writer may have something to help us.

  6. Joseph Avatar
    Joseph

    Hey Guys,
    We are in the process of converting all of our Reports from Crystal to CF7. We encountered a situation where we need to retrieve the Query that’s embedded in the Report. Is there a way out using CFML code?

  7. Carlos M Avatar
    Carlos M

    Are there any good resources out there that focus on CFREPORT and the CF Report Builder. I’m interesting in creating a report "package" that contains multiple pages with unrelated queries.

  8. Ben Forta Avatar
    Ben Forta

    Carlos,
    You might want to try http://www.cfreport.org/, although it’s not been updated in a while.
    — Ben

  9. Ray Bailey Avatar
    Ray Bailey

    I’m having difficulty getting report functions to work. Looking at the documentation, I followed the steps to creating a function (which seems to be a ColdFusion function) and inserted it into the report. The purpose of the function is to display an address. Some records may have 2 address lines, others 3 or 4 depending on the address. I figured the function would determine that if adress line 2 or 3 were not null/blank, display it. If they were blank/null, don’t display them along with address line 1 and 4. Although I get no errors when the report displays, the function doesn’t seem to evaluate…it just displays a cryptic "placeholder" where the function output is suppossed to be that consists of a combination of letters, numbers, and symbols (e.g., cffunc@123344355444455$$-hghkl455). I tried creating another simple function just to ouput a static variable as a test but it does the same thing. Any ideas?

Leave a Reply