Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 649
  • Last Modified:

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?).
0
incapital
Asked:
incapital
  • 3
  • 3
1 Solution
 
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

0
 
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.

0
 
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...
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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?
0
 
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.
0
 
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.
0
 
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.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now