<HTML>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=charset=UTF-8">
<BODY>
<%
'===================================================================
'Declare the CMS Logon Variables
Dim CMS
Dim Username
Dim Password
Dim Authtype
'Set CMS logon credentials - change these to match your particular CE environment
CMS = "<YOURCMSHERE>"
Username = "ReadOnly" [COLOR=red] 'special account [/color]
Password = "sample123"
Authtype = "secEnterprise"
'Declare variables for Enterprise Session
Dim oEnterpriseSessionMgr
Dim ceSession
Dim iStore
'Get the values
Rid = Request.QueryString("ReportID")
NbrParams = Request.QueryString("NumParens")
If NbrParams > 0 then
ValStr = Request.QueryString ("Pvals")
NameStr = Request.QueryString ("Pnames")
arrVals = Split(ValStr,";")
arrNames = Split(NameStr,",")
End If
'Load the Enterprise Session Manager
Set oEnterpriseSessionMgr = Server.CreateObject("CrystalEnterprise.SessionMgr")
'Logon to the CMS and create iStore object
Set ceSession = oEnterpriseSessionMgr.Logon(Username, Password, CMS, Authtype)
Set iStore = ceSession.Service("","InfoStore")
'Declare InfoObject Variable
Dim Reports
Dim Report
'Dim Qry
'Query the CMS for the report you wish to view
Set Reports = iStore.Query("Select * from CI_InfoObjects Where SI_ProgID = 'CrystalEnterprise.Report' and SI_ID='" & Rid & "'")
Report = Reports.Item(1).Properties("SI_ID")
'Qry = Reports.SQLQueryString
'Declare the report parameter variables
Dim reportParameters
Dim fields
Dim tmpParameter
Dim value
Dim NewSpec()
Dim PType()
Dim inx
Dim pcnt
pcnt = 0
inx = 0
'Get the report parameter(s) using the plugin interface
Set reportParameters = Reports.Item(1).PluginInterface("Report").ReportParameters
If NbrParams > 0 then
' Build an array structure to determine the parameter type
For each parameter in reportParameters
pcnt = pcnt + 1
Next
For each parameter in reportParameters
ReDim PType(pcnt)
PType(inx) = parameter.ValueType
inx = inx + 1
Next
'Create a new Fields Collection Object
Set fields = CreateObject("CrystalReports.Fields")
for n = 0 to (NbrParams - 1)
' Create a temporary parameter field
Set tmpParameter = CreateObject("CrystalReports.ParameterField")
' Create list of values for this parameter
arrPvals = Split(arrVals(n),",")
Max = UBound(arrPvals)
ReDim NewSpec(Max)
' Create a parameter value oblect for each value in list
for v = 0 to UBound(arrPvals)
set NewSpec(v) = createobject("CrystalReports.ParameterFieldDiscreteValue")
Next
i = 0 ' initialize counter for value list array access
for each val in arrPvals ' assign the value to the parameter
if PType(n) = 3 then
NewSpec(i).value = cDate(val)
else
NewSpec(i).value = Trim(val)
end if
tmpParameter.CurrentValues.Add NewSpec(i)
i = i + 1 ' increment counter
Next
tmpParameter.name = arrNames(n)
Fields.Add tmpParameter
Next ' parameter
End If
'Declare the Report App Factory and Report Document Objects
Dim rptAppFactor
Dim reportDocument
'Create the Report App Factory and Report Document Objects
Set rptAppFactory = iStore.EnterpriseSession.Service("","PSReportFactory")
Set reportDocument = rptAppFactory.OpenReportSource(Report)
'Declare the viewer object variable
Dim Viewer
'Create a viewer object and view the report
Set Viewer = CreateObject("CrystalReports.CrystalReportInteractiveViewer")
With Viewer
.reportSource = reportDocument
.HasBooleanSearchButton = False
.HasCrystalLogo = False
If NbrParams > 0 then
.ParameterFields = Fields
End If
.HasRefreshButton = True
.IsDisplayGroupTree = False
.HasPrintButton = true
.PrintMode = 0 ' disable activeX Printing - set to 1 to enable (may require plug-in if set to 1)
.IsOwnPage = true
End With
'
Set Session("viewer") = Viewer
Response.Redirect("viewprint.asp")
%>
</BODY>
</HTML>