Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal with Coldfusion

Status
Not open for further replies.

pandi

Programmer
Dec 12, 2001
22
MY
I'm fairly new to crystal.

We are using Coldfusion 4.5.2 with Crystal reports v 8 to generate the dynamic reports . i.e opening existing reports and add some database fields on fly and we are creating report on web dynamically.There are lots of example code available on seagate site for ASP.But nothing is available for Coldfusion.But i'm trying to create the reports on fly using coldfusion after spending much time in seeing ASP codes examples.Still i'm not clear how to run the reports on fly.I have attached the code for you guys to review.I'm getting errors like "Server has not been opened yet". Is there any help or example codes available for intergrating Crystal Report Designer Components in Coldfusion.

Please, I'll appreciate any help you can give me.

Thanks, Pandi

Code :


<CFOBJECT ACTION=&quot;CREATE&quot; NAME=&quot;CrysRep&quot; CLASS=&quot;CrystalRuntime.Application&quot;>
<cfset Report = CrysRep.OpenReport(&quot;#CRWRptDir#\#sMode#\Temp\#Client.ClientID#-Labels.rpt&quot;)>
<cfset Frfields = Report.FormulaFields>
<cfset Frfields = Frfields.Add(&quot;Test&quot;,&quot;{Contact.SSN}&quot;)>
<cfset Report.RecordSelectionFormula = &quot;#sSelect#&quot;>
<cfset rc = Report.ReadRecords()>

 
I'm using practically the same setup!! We have had great success integrating the products using Recrystalize. It can create an htm or asp calling script.

Not to worry, the code is created for you by a wizard and you can simply modify the calling templates. I'm using a report today through the web report with 5 subreports, 15 tables, a number of variables etc with no problem in calling it.

It writes script and ASP files that would take me days to do in seconds.

Contact
Here's an example of what it creates...


<html>

<head>
<meta http-equiv=&quot;Content-Type&quot;
content=&quot;text/html; charset=iso-8859-1&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;ReCrystallize Web Publishing Wizard for Seagate Crystal Reports 3.0.3&quot;>
<title>Please make your selections for the report</title>
<SCRIPT>
function writemonthselect( prev_or_cur, parmname ) {
today = new Date()
thismonth = today.getMonth() + 1
if (prev_or_cur == 'prev') {
if (thismonth == 1) {
var monthtoselect = 12
} else {
var monthtoselect = thismonth -1
}
} else {
var monthtoselect = thismonth
}
var selstr = &quot;<select NAME=\&quot;&quot; + parmname + &quot;\&quot; SIZE=\&quot;1\&quot;>&quot;
selstr += &quot;<OPTION VALUE=\&quot;01\&quot;&quot;
if (monthtoselect == 1) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>January&quot;
selstr += &quot;<OPTION VALUE=\&quot;02\&quot;&quot;
if (monthtoselect == 2) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>February&quot;
selstr += &quot;<OPTION VALUE=\&quot;03\&quot;&quot;
if (monthtoselect == 3) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>March&quot;
selstr += &quot;<OPTION VALUE=\&quot;04\&quot;&quot;
if (monthtoselect == 4) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>April&quot;
selstr += &quot;<OPTION VALUE=\&quot;05\&quot;&quot;
if (monthtoselect == 5) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>May&quot;
selstr += &quot;<OPTION VALUE=\&quot;06\&quot;&quot;
if (monthtoselect == 6) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>June&quot;
selstr += &quot;<OPTION VALUE=\&quot;07\&quot;&quot;
if (monthtoselect == 7) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>July&quot;
selstr += &quot;<OPTION VALUE=\&quot;08\&quot;&quot;
if (monthtoselect == 8) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>August&quot;
selstr += &quot;<OPTION VALUE=\&quot;09\&quot;&quot;
if (monthtoselect == 9) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>September&quot;
selstr += &quot;<OPTION VALUE=\&quot;10\&quot;&quot;
if (monthtoselect == 10) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>October&quot;
selstr += &quot;<OPTION VALUE=\&quot;11\&quot;&quot;
if (monthtoselect == 11) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>November&quot;
selstr += &quot;<OPTION VALUE=\&quot;12\&quot;&quot;
if (monthtoselect == 12) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>December&quot;
selstr +=&quot;</select>&quot;

return selstr
}


function writedateselect( prev_or_cur, parmname ) {
today = new Date()
thisdate = today.getDate()
if (prev_or_cur == 'prev') {
if (thisdate == 1) {
var datetoselect = 31
} else {
var datetoselect = thisdate -1
}
} else {
var datetoselect = thisdate
}
var selstr = &quot;<select NAME=\&quot;&quot; + parmname + &quot;\&quot; SIZE=\&quot;1\&quot;>&quot;
for (var d = 1; d <= 31; d++) {
selstr += &quot;<OPTION VALUE=\&quot;&quot; + d + &quot;\&quot;&quot;
if (datetoselect == d) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>&quot; + d
}
selstr +=&quot;</select>&quot;

return selstr
}


function writeyearselect( prev_or_cur, parmname ) {
today = new Date()
thisyear = today.getFullYear()
if (prev_or_cur == 'prev') {
var yeartoselect = thisyear -1
} else {
var yeartoselect = thisyear
}
var selstr = &quot;<select NAME=\&quot;&quot; + parmname + &quot;\&quot; SIZE=\&quot;1\&quot;>&quot;
for (var y = 1987; y <= thisyear; y++) {
selstr += &quot;<OPTION VALUE=\&quot;&quot; + y + &quot;\&quot;&quot;
if (yeartoselect == y) {
selstr += &quot; SELECTED&quot;
}
selstr += &quot;>&quot; + y
}
selstr +=&quot;</select>&quot;

return selstr
}


function writedate( style, prev_or_cur, parmnum) {
// style is mdy | my | y
// prev_or cur is prev | cur for the previous or current period
// parmnum is an integer for the parameter number
initdate = new Date()
if ( style == 'y' ) {

allsel = writeyearselect( prev_or_cur, 'P' + parmnum + 'Y' )
}

if ( style == 'my' ) {
allsel = writemonthselect( prev_or_cur, 'P' + parmnum + 'M' )
if (( prev_or_cur == 'prev' ) &amp;&amp; ( initdate.getMonth() + 1 == 1 )) {
allsel += writeyearselect( 'prev', 'P' + parmnum + 'Y' )
} else {
allsel += writeyearselect( 'cur', 'P' + parmnum + 'Y' )
}
}
if ( style == 'mdy' ) {
dcp = 'cur'
mcp = 'cur'
ycp = 'cur'
if ( prev_or_cur == 'prev' ) {
dcp = 'prev'
if ( initdate.getDate() == 1 ) {
mcp = 'prev'
if ( (initdate.getMonth() + 1) == 1 ) {
ycp = 'prev'
}
}
}
allsel = writemonthselect( mcp, 'P' + parmnum + 'M' ) + writedateselect( dcp, 'P' + parmnum + 'D' ) + writeyearselect( ycp, 'P' + parmnum + 'Y' )
}
return allsel
}

function validateandsubmit( f ) {
tmpy = document.parmform.P0Y.options[document.parmform.P0Y.options.selectedIndex].value
tmpm = document.parmform.P0M.options[document.parmform.P0M.options.selectedIndex].value
tmpd = document.parmform.P0D.options[document.parmform.P0D.options.selectedIndex].value
tdate = new Date( tmpy, tmpm - 1, tmpd )
nty = tdate.getFullYear()
ntm = tdate.getMonth() + 1
ntd = tdate.getDate()
document.parmform.prompt0.value = 'Date(' + nty + ', ' + ntm + ', ' + ntd + ')'
tmpy = document.parmform.P1Y.options[document.parmform.P1Y.options.selectedIndex].value
tmpm = document.parmform.P1M.options[document.parmform.P1M.options.selectedIndex].value
tmpd = document.parmform.P1D.options[document.parmform.P1D.options.selectedIndex].value
tdate = new Date( tmpy, tmpm - 1, tmpd )
nty = tdate.getFullYear()
ntm = tdate.getMonth() + 1
ntd = tdate.getDate()
document.parmform.prompt1.value = 'Date(' + nty + ', ' + ntm + ', ' + ntd + ')'
document.parmform.submit()
}
</SCRIPT>
</head>

<body bgcolor=&quot;#FFFFFF&quot;>

<p><font size=&quot;5&quot;><strong>Data list</strong></font></p>

<form action=&quot;mainreport.rpt&quot; method=&quot;POST&quot; name=&quot;parmform&quot;>
<input type=hidden name=&quot;init&quot; value=&quot;actx&quot;>
<input type=hidden name=&quot;promptOnRefresh&quot; value=1>
<table border=&quot;1&quot;>
<tr>
<td>Begin date</td><td>
<SCRIPT>
document.write( writedate( 'mdy', 'prev', '0' ) )
</SCRIPT>
<input name=&quot;prompt0&quot; type=&quot;hidden&quot; value= &quot;&quot;>
</td>
</tr>
<tr>
<td>Begin date</td><td>
<SCRIPT>
document.write( writedate( 'mdy', 'prev', '1' ) )
</SCRIPT>
<input name=&quot;prompt1&quot; type=&quot;hidden&quot; value= &quot;&quot;>
</td>
</tr>
<tr>
<td>Choices</td><td>
<input type=&quot;text&quot; size=&quot;10&quot; maxlength=&quot;10&quot; name=&quot;prompt3&quot;></td>
</td>
</tr>
<tr><td colspan=&quot;2&quot;><p align=&quot;center&quot;>
<INPUT TYPE=&quot;BUTTON&quot; VALUE=&quot;View Report&quot; onClick=&quot;validateandsubmit(this.form)&quot;>
</td>
</tr>
</table>
</form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top