How to reference an input parameter in a function

Posted on 2006-03-27
Last Modified: 2013-12-16
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?).
Question by:incapital
    LVL 42

    Expert Comment

    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:

    LVL 3

    Author Comment

    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.

    LVL 42

    Expert Comment

    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...
    LVL 3

    Author Comment

    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?
    LVL 42

    Accepted Solution

    >>> 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.
    LVL 16

    Expert Comment

    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.
    LVL 3

    Author Comment

    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.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
    The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
    The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now