Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, November 25, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Crystal report runs fine once, then hangs for several minutes on subsequent runs.
Adam Conde
Posts: 14
 
Crystal report runs fine once, then hangs for several minutes on subsequent runs.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jul 07 1:54 PM
I have a function that I use to print, preview, and/or attach a crystal report. (See below)

It works fine the first time I run it. Then any subsequent runs will hang on either the printOut or export (depending on what the function was asked to do)

objRDC.Export False
-or-
objRDC.PrintOut false,1,false,1,99

It may hang for up to 5 minutes. And when it's hanging it appears to be doing nothing. It's not locked up and there are no SQL locks. It just sits there.

Any ideas? Thanks in advance!

...Adam

Sub doCrystal (byval strReportName, byVal strEntityID, byVal strDescription, byVal strParam1, byVal strParam2, byVal strParam3, byVal strParam4, byVal boolPreview, byVal boolPrint, byVal boolAttach)
dim objRDC, objFSO, objParam1, objParam2, objParam3, objParam4
dim strFullFileName, objWShell, x

set objRDC = Application.BasicFunctions.GetCrystalReport(strReportName)
if isobject(objRDC) then
if not isNull(strParam1) then
set objParam1 = objRDC.ParameterFields.Item(1)
objParam1.SetCurrentValue (strParam1)
if not isNull(strParam2) then
set objParam2 = objRDC.ParameterFields.Item(2)
objParam2.SetcurrentValue (strParam2)
if not isNull(strParam3) then
set objParam3 = objRDC.ParameterFields.Item(3)
objParam3.SetCurrentValue (strParam3)
if not isNull(strParam4) then
set objParam4 = objRDC.ParameterFields.Item(4)
objParam4.SetcurrentValue (strParam4)
end if
end if
end if
end if

set objWShell = CreateObject("WScript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")
if not objFSO.FolderExists(cDirectory) then
objFSO.CreateFolder(cDirectory)
end if

strFullFileName = cDirectory & "\" & cFileName

if boolPrint then
objRDC.PrintOut false,1,false,1,99
end if
if boolPreview or boolAttach then
objRDC.ExportOptions.DestinationType = 1 'disk
objRDC.ExportOptions.FormatType = 31 'PDF
objRDC.ExportOptions.DiskFileName = strFullFileName
objRDC.Export False
end if

set objRDC = Nothing
else
msgbox "Error generating document"
exit sub
end if

if objFSO.FileExists(strFullFileName) then
if boolPreview then
x = objWShell.Run (strFullFileName,1,True)
end if
if boolAttach then
if not addAttachment(strEntityID, strFullFileName, strDescription) then
msgbox "Error attaching report"
end if
else
objFSO.DeleteFile(strFullFileName) 'delete the temp file if we're not creating an attachment. Otherwise, addAttachment will cleanup.
end if
end if
set objFSO = Nothing
end sub

[Reply][Quote]
Adam Conde
Posts: 14
 
Re: Crystal report runs fine once, then hangs for several minutes on subsequent runs.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jul 07 2:00 PM
Oh, we're running v6.2.6
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Crystal report runs fine once, then hangs for several minutes on subsequent runs.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Jul 07 8:21 AM
There are a lot of conditional statements.

Are you making sure all objects are being set to Nothing before leaving the Sub?

You might want to change creating all objects at the beginning of the sub and destroying all of them at the end of the sub. This way they exist if needed and are destroyed when the sub is done.

John G.
[Reply][Quote]
Adam Conde
Posts: 14
 
Re: Crystal report runs fine once, then hangs for several minutes on subsequent runs.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Jul 07 12:41 PM
I noticed that I wasn't closing the WShell object nor the objParam objects. I've fixed that, but I'm still having the same problem.
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Crystal report runs fine once, then hangs for several minutes on subsequent runs.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 24 Jul 07 8:10 AM
What version of Crystal Reports 8.5 is installed on the box this is happening on?

My past experience has been that the version of Crystal should only be the version that comes with SalesLogix. And do not apply updates to that version either.

John G.
[Reply][Quote]
Adam Conde
Posts: 14
 
Re: Crystal report runs fine once, then hangs for several minutes on subsequent runs.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 24 Jul 07 4:44 PM
oh yes, we are well aware that Crystal is tempermental when it comes to patches and updates, so we're running the out-of-the-box version that comes with SLX.

The problem appears to be with how Crystal is handing parameters which are used to filter the records returned by the report. So what I have done is removed all criteria from the "Select Expert" in crystal reports.

Instead I am using objRDC.SQLQueryString set the report SQL. So I am passing a "Where" clause to the sub which I append to the report's SQL statement. And now it works perfectly! Now I just need to modify my reports to remove the select criteria from the report and handle that instead through script.

strSQL = objRDC.SQLQueryString 'get report SQL
strSQL = strSQL & " " & strWhere 'append where clause
objRDC.SQLQueryString = strSQL
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Crystal report runs fine once, then hangs for several minutes on subsequent runs.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Jul 07 8:11 AM
Ah.. You hit on it..

The problem appears to be with how Crystal is handing parameters which are used to filter the records returned by the report.


I was just teaching someone about this yesterday. Apparently the data you are querying is a large dataset. When you have parameters in Crystal it does client side processing. So what happens is the client has to wait for ALL of the data to come down to it from the server. So you might have to wait for 100,000 records to be received by the client that then is filtered by the client.

When you changed the method by appending the WHERE condition to the SQL all the processing of the SQL is done on the server (server side processing). This takes a huge load off of the network and can speed up response time immensely. The result is only filtered data is returned from the server - not the 100,000 for example.

What I try to do for many of the customer reports done here is create a VIEW of the exact data I need for the report. By creating a VIEW you eliminate ALOT of the complexity of creating all of the necessary JOINs and conditions in Crystal. When the VIEW has the exact data needed for the report you are left with only having to specify ONE table to use in Crystal and can progress rather quickly through the process of formatting the report.

John G.

[Reply][Quote]
Adam Conde
Posts: 14
 
Re: Crystal report runs fine once, then hangs for several minutes on subsequent runs.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Jul 07 2:46 PM
I see how using a VIEW would help, but using a VIEW wouldn't eleminate the need to pass a parameter like opportunityid to the report so that the records can be filtered. So a VIEW might improve performance related to JOINS, but wouldn't I still encounter the same problem since I'm still passing a parameter and it is the parameters that causes the main problem because they cause Crystal to do client side processing?
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Crystal report runs fine once, then hangs for several minutes on subsequent runs.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 30 Jul 07 2:18 PM
You explained earlier how you were adding conditions to the SQL statement via code. You can do the same exact thing for a view. The difference is you do not have the complexities of having to handle multiple tables and large amounts of unnecessary data within CR.

John G.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/25/2024 6:37:29 AM