Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, February 23, 2025 
 
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: Script to preview a Crystal Report with two CR Parameter fields
Mike Mahoney
Posts: 34
 
Script to preview a Crystal Report with two CR Parameter fieldsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Dec 06 2:37 PM
fiogf49gjkf0d
Hi Everyone,

I want to use VB Script to fire a report preview. There are two Crystal Parameters that I need to fill in the script - a Date and a UserID. I can get the report object opened and feed the report parameters through the RDC, but don't quite know what to do next if I want to preview the report through the CRW Viewer:

sub Preview_Report (Sender)
dim objRDC, objParam1, objParam2, strUserID, objCRWViewer
strUserID = Application.BasicFunction.currentUserID
set objRDC = Application.BasicFunctions.GetCrystalReport("Sales Dept Reports:Pipeline Report - Individual AE - Current User")
set objParam1 = objRDC.ParameterFields.Item(1)
set objParam2 = objRDC.ParameterFields.Item(2)
objParam1.SetCurrentValue (date)
objParam2.SetcurrentValue (strUserID)
' Initialize the CRW Viewer
set objCRWViewer = CreateObject ("CrViewer.CrViewer")
' **********************************
' What do I do now??
'**********************************
set objCRWViewer = Nothing
set objParam1 = Nothing
set objParam2 = Nothing
set objRDC = Nothing
end sub

Where do I proceed to get the report set up in objRDC to display n the screen?
[Reply][Quote]
Mike Mahoney
Posts: 34
 
Re: Script to preview a Crystal Report with two CR Parameter fieldsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Dec 06 3:15 PM
fiogf49gjkf0d
Sounds like I ventured into uncharted territory based on the thunderous response. Seems opening a Crystal Report object through Application.BasicFunctions.GetCrystalReport causes the resulting object to be "one layer too far in" to work with the Crystal Viewer object.

My work-around was to export the report to a PDF file and open it using the "WScript.Shell" object....
----------------------------------------------------------------------------------------
sub Preview_Report (Sender)
dim objRDC, objParam1, objParam2, strUserID, objCRWViewer, objWShell, objFSO, x

strUserID = Application.BasicFunction.currentUserID
set objRDC = Application.BasicFunctions.GetCrystalReport("Sales Dept Reports:Pipeline Report - Individual AE - Current User")

set objParam1 = objRDC.ParameterFields.Item(1)
set objParam2 = objRDC.ParameterFields.Item(2)
objParam1.SetCurrentValue (date)
objParam2.SetcurrentValue (strUserID)
objRDC.ExportOptions.DestinationType = 1 'Disk File
objRDC.ExportOptions.DiskFileName = strFullFileName
objRDC.ExportOptions.FormatType = 31 'PDF
objRDC.Export False

set objWShell = CreateObject("WScript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")

if objFSO.FileExists (strFullFileName) then
x = objWShell.Run (strFullFileName,1,True)
end if

if objFSO.FileExists (strFullFileName) then
objFSO.DeleteFile (strFullFileName)
end if

set objWShell = Nothing
set objFSO = Nothing
set objParam1 = Nothing
set objParam2 = Nothing
set objRDC = Nothing
end sub
----------------------------------------------------------------

It can look like the system hangs when the report is being generated, so I wrapped this code around a manage form with a progress bar so the user knows where in the progress cycle the report it. Works pretty well.

-Mike
[Reply][Quote]
fbw
Posts: 3
 
Re: Script to preview a Crystal Report with two CR Parameter fieldsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Aug 10 1:30 PM
I had been struggling with this as I was recently told the same thing from SLX SDK Support that the GetCrystalReport object was "one layer too far in" to work with the Crystal Viewer object... but then my good friend Kelly Small rocked my world with the code sample below! Apparently you CAN generate a Crystal Report Object and view it in the Crystal Viewer now! I thought I would share this groundbreaking code with all.

dim objRDC, objMainView, objDetail

set objRDC = Application.BasicFunctions.GetCrystalReport("Personal:Report")
objRDC.DiscardSavedData()

'filter report
objRDC.RecordSelectionFormula = "{Table.Field} = 'value'"

'or pass parameters as Mike Mahoney does above...
set objParam1 = objRDC.ParameterFields.Item(1)
set objParam2 = objRDC.ParameterFields.Item(2)
objParam1.SetCurrentValue (date)
objParam2.SetcurrentValue (strUserID)

Set objMainView = Application.MainViews.Add("System:SLX Crystal Report Viewer", 2, False)

objMainView.Height = 600
objMainView.Width = 800
objMainView.Caption = Application.Translator.Localize("Sage SalesLogix Crystal Reports Viewer") 'title

Set objDetail = objMainView.DetailsView

objDetail.Script.Display objRDC

objMainView.Show 'show report in non-modal dialog

'clear objects
Set objDetail = Nothing
Set objMainView = Nothing
[Reply][Quote]
Douglas Walker
Posts: 27
 
Re: Script to preview a Crystal Report with two CR Parameter fieldsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jul 12 10:10 AM
fiogf49gjkf0d

Thank you fbw and Kelly Small. 


This is exactly what I was looking for. Smile

[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 © 2025 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): 2/23/2025 12:35:17 PM