Print Results After Post

vasquezm used Ask the Experts™
I have a Coldfusion Search page that posts to itself, when complete cfgrid displays the results of the post based upon a bind to a CFC from the form scope.

Because of the Search criteria being used and the amount of data, I want to provide the user with the ability to print the results after they have verified that the information is correct.  

I have duplicated the form scope to the request scope after post.

The problem I am having is passing the form scope or request scope variables to another page for processing to a Coldfusion Report for printing.  The scoped variables do not remain.

The provide additional detail, I used a variable in the action page for the form, on the first submit it posts to itself.  After post the action page is another page print_results.cfm which I want to take the scoped variables, pass to a cfc using cfinvoke and then the results passed to a ColdFusion Report.

General code would help greatly as I need to understand how to retain and pass the scope.  not sure if or how the form scope needs to be sent to a cfc to retain to the new action page.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Simple way is use cfdump (but not useful in application)

<cfdump var=”#form#”>

Within an application, you can loop over a collection that is created when a form is submitted. That collection contains the form field names, and you can use those field names to reference the values that exist in the fields.

<cfloop item="fname" collection="#form#">
<cfoutput>#fname# - #form[fname]#<br></cfoutput>

This code simply displays the fields and their values, but you can use the information to do a database insert or manipulate the corresponding data however you like.

There is also a list created of the fieldnames as an attribute of the form collection that you can access by referencing form.fieldnames:

<cfloop item="fname" list="#form.fieldname#">
<cfoutput>#fname# - #form[fname]#<br></cfoutput>
"I have duplicated the form scope to the request scope after post."

Are you are using cflocation to move to your print page? If so, this generates a new request and your request vars are lost. Simplest is to pass var in url scope. You can also use session scope if security considerations make using url vars impractical.


I was able to keep within the session scope, and prior to the print I drop the session vars to make sure that it does not persist for the next search / print.  

Now off to the easy part, option to send to excel.

Thanks everyone for the help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial