How to reference an input parameter in a function

I have several Crystal Reports that we call from a ColdFusion application. I can pass parameters into the reports to filter data without any problems when I call the report:

{mytable.mycolumn} = myvariable;

This works well for building record selection formulas dynamically. But as I start to build more complex reports, I've run across several places where I need to reference those input parameters in functions inside the report. How do I do this?

Many thanks.


I tried defining parameters in my report and calling them from the ColdFusion app like this:

{?myinputvar} = myvariable;

But this causes the report to hang (waiting for a prompt response maybe?).
Who is Participating?
>>> Let's say that I want to print my input parameter at the top of my report. What is the syntax I would use to reference it?

If it is a true Crystal parameter then in your report design you can simply drag the parameter from the Field Explorer onto your report and it will print.

Of if you prefer within Crystal you can create a formula that simply returns the parameter as in:

  // @MyFormula

All of this holds true for a parameter created within Crystal Reports (i.e.: It appears in the Field Explorer under the 'Parameters' tree).

Just in case we have a difference in symantics:  If you don't have a Crystal parameter but are instead simply setting the selection criteria directly with code such as {table.column} = value    then you won't be able to show the value.  You will instead need to create a Crystal parameter and pass it in.
I don't use ColdFusion myself, but there's some code posted in a previous question that includes passing in parameters and seems to have worked:

incapitalAuthor Commented:
Thanks for your response. I'm actually not having any problems passing parameters from ColdFusion to Crystal Reports. My problem is that I don't know how I can reference those parameters within Crystal Reports if I need to use them for a function, subreport, etc...

Hope that clarifies things a bit.

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Are you trying to have your application use the Crystal parameters?  If so, then there's no way to do this feasibly.

Within Crystal your formula can reference a parameter with the syntax you have {?ParameterName}.  However, within a formula you cannot assign a new value to a parameter - the value assigned when the report is first called remains in the parameter throughout the creation of the report.  If this is what you're trying to do then within Crystal you'd want to assign the parameter to a variable (  numberVar MyVariable := {?MyParameter} ) and then later in the report you can change the value assigned to the variable.

If I'm still missing the point please let me know...
incapitalAuthor Commented:
Thanks for your comment. I'm not having any problems getting parameters into my reports, and I don't need to access them outside my report.

Perhaps I can clarify the problem with this example... I call the report from my application, and I pass in a parameter:

{tablename.columnname} = myvariable

The variable I've called 'myvariable' is passed in to the report and used to build a dynamic select statement. That is working perfectly.

Let's say that I want to print my input parameter at the top of my report. What is the syntax I would use to reference it?
Well that depends on what information is contained within the parameter.  If is contains codes but he want to display descriptions, you will need to create a sub-report and then link the parameter to the value in the subreport (as I am not aware of a way to display the desciption of a parameter). This comes into serious play on parameters that have multiple selections.  Otherwise a formula would work.
incapitalAuthor Commented:
You answer that I can't display dynamic selection criteria in my report appears to be correct. Those dynamic selection criteria appear to be my only option to pass parameters into a Crystal Report. These are not named parameters within Crystal Reports, and while they work well in building a dynamic select statement, there doesn't appear to be any way to display them within the report.

I don't believe that one has the ability to pass named parameters (i.e. parameters that are created witin Crystal Reports) from a ColdFusion application. The webserver times out while it waits for a response to the prompt. If one wants to pass named parameters, I believe one has to use something that is more tightly integrated with Crystal Reports, like ASP.

I have seen people pass named parameters in a URL string as a sort of kludgey fix in ColdFusion (i.e. http://myreportserver/myreport.rpt?prompt0=123&promptOnRefresh=0), but this requires Crystal Reports to be installed on the client machine, and creates security problems by passing too much information in URL strings.

I've tried at length to find a workable solution to this using ColdFusion and the cfreport tag, but I've not had any success. I built a simple report with one parameter defined in Crystal Reports, and attempted to pass in a value from my ColdFusion application.

I've tried each of the following to pass a named parameter into a Crystal Report:

<cfreport  report="#GetDirectoryFromPath(CF_TEMPLATE_PATH)#promptTest.rpt" datasource="mydb" username="myname" password="mypw"


<cfreport  report="#GetDirectoryFromPath(CF_TEMPLATE_PATH)#promptTest.rpt" datasource="mydb" username="myname" password="mypw">
    {?myprompt} = 123;

As well as a whole lot of permutations thereof. The result is always the same -- the page hangs until it times out. Because of the way ColdFusion integrates with Crystal Reports, it appears that Crystal is not aware that it's being requested via the web, and waits forever for a respons to a prompt that the web user never sees.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.