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.

P.S.

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?).
LVL 3
incapitalAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

frodomanCommented:
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: http://www.experts-exchange.com/Databases/Crystal_Reports/Q_21096219.html

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.

frodomanCommented:
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...
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

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?
frodomanCommented:
>>> 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
  {?MyParameter}

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wykabryanCommented:
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"
      formula="prompt0=123;PromptOnRefresh=0;">
</cfreport>

AND

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

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.