2/23/2025 6:57:24 AM
|
|
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!
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.
|
|
|
|
Script to preview a Crystal Report with two CR Parameter fields
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? |
|
|
|
Re: Script to preview a Crystal Report with two CR Parameter fields
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 |
|
|
|
Re: Script to preview a Crystal Report with two CR Parameter fields
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 |
|
|
| |
|
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!
|
|
|
|
|
|
|
|