User Guide

Table Of Contents
798 Chapter 32: Creating Reports for Printing
delimiter=","
firstrowasheaders="no">
Another possible use of advanced query mode is to test for passed parameters in the URL or
FORM scopes and use these parameters to retrieve data, as the following example shows:
<!--- First look for URL parm.
URL overrides cfreportparam. --->
<cfif isDefined("url.deptidin")>
<cfset param.deptidin = url.deptidin>
</cfif>
<!-- Then look for FORM parm. Overrides URL parm. --->
<cfif isDefined("form.deptidin")>
<cfset param.deptidin = form.deptidin>
</cfif>
<cfquery name="CFReportDataQuery" datasource="cfdocexamples">
SELECT LastName, FirstName, Dept_ID
FROM Employee
WHERE (Dept_ID = #param.deptidin#)
</cfquery>
Report functions
Report functions are user-defined CFML functions that you code using the Report Function
Editor and invoke in report fields. You can use them to format data (such as concatenating and
formatting all the field that make up an address), to retrieve data, and for many other purposes.
To create a report function:
1.
Select Report > Report Functions from the menu bar.
The Report Function Editor displays.
2.
Click the plus sign to add a new report function.
The Add Report Function dialog box displays.
3.
Specify a name and click OK.
4.
The Report Function Editor places a cfreturn tag in the text entry area.
5.
Code the function. This is a ColdFusion user-defined function so all UDF rules and features
are available for use. The following example show a report function that concatenates address
fields:
<cfargument name="Name" required="yes"/>
<cfargument name="Address1" required="yes"/>
<cfargument name="Address2" required="yes"/>
<cfargument name="City" required="yes"/>
<cfargument name="State" required="yes"/>
<cfargument name="Zip" required="yes"/>
<cfset variables.CRLF = Chr(13) & Chr(10)>
<cfset variables.ResultVar="">
<cfif Trim(arguments.Name) NEQ "">