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!
|
|
Can someone tell me how I would go about passing a value from saleslogix to a crystal report?
Posted: 29 Sep 08 12:55 PM
|
Can someone tell me how I would go about passing a value from saleslogix to a crystal report?
I have a report that is already being called from SLX and a when open event that calls a script to filter the report. All I need to do now is pass the current user name that I already have stored in a variable in the open script to the crystal report. This seems so simple so I think I may be making this a litter harder than it should be. Just a guess, but I would assume I could use the .ReportAddCondition function in some way to achieve this, but can't figure out how to get it done.
THx in advance. -RJ |
|
|
|
Re: Can someone tell me how I would go about passing a value from saleslogix to a crystal report?
Posted: 29 Sep 08 1:46 PM
|
Hi RJ,
From DevLogix III.7 (and the Companion):
ReportAddCondition (Field, Op, Val, ValType, Conn) This function should be called from a script that is invoked by the When Open event of a report. It passes one or more conditions through to the Crystal Report engine.
The Field value is the “qualified” field name of the database field that you want to add the condition on. If the field is in the Main Table of the report then the qualified name is TABLE:FIELDNAME – e.g. CONTACT:LASTNAME. If the field is not in the Main Table of the report, then you need to use the SalesLogix arcane join syntax:
TABLE1:FIELD1(=|>|<)FIELD2.TABLE2!CONDITION_FIELD
Stephen www.slxmaster.com
|
|
|
|
Re: Can someone tell me how I would go about passing a value from saleslogix to a crystal report?
Posted: 29 Sep 08 1:54 PM
|
Hi Stephen, thanks for the reply. I am only passing a name to display in the report. This report displays information based on a custom table that is joined to the account table. The value I need is from userinfo so there would be no join possible to create. What I actually want to do is not really passign a condition, but passing a variable simply for displaying a username at the report footer. I hope I didn't missunderstand your reply.
Here is an example of what I have already, I just need to get strUser to the crystal report:
'Including Script - Personal:DEFAULT_CLS option explicit sub Main
Dim AcctID, strUser
AcctID = Application.GlobalInfo("g_TemporaryAcctID")
'get username Dim objcls Set objcls = New Palombo_Default
Dim strUserID strUserID = application.BasicFunctions.CurrentUserID
objcls.Initialize strUser = objcls.GetUserInfo(strUserID).Fields(2).value objcls.Terminate
With Application.BasicFunctions .ReportClearConditions .ReportAddCondition "C_AccountBIData:AccountID", "=", "'" & AcctID & "'" , "string", "" .GlobalInfoClear "g_TemporaryAcctID" End With
end sub
Now I was hoping to use a line like below to "trick" SLX into passing my var: .ReportAddCondition "", "", "'" & strUser & "'" , "string", "ParamUser" - Created parameter field in crystal to hopefully display userid passed from this line
-RJ |
|
|
| |
|
Re: Can someone tell me how I would go about passing a value from saleslogix to a crystal report?
Posted: 30 Sep 08 7:52 AM
|
Hi Stephen,
Well without checking I went ahead and researched the GetCrystalReport method and I ran into a problem in my code at the very end. There is no crystal report viewer control that I can see.
Here is my code below:
Sub ShowReport
Dim objReport, objReportMV, strFilter, AcctID, strUser AcctID = Application.BasicFunctions.CurrentAccountID 'get username Dim objFISERVcls Set objFISERVcls = New Fiserv_Palombo_Default
Dim strUserID strUserID = application.BasicFunctions.CurrentUserID
objFISERVcls.Initialize strUser = objFISERVcls.GetUserInfo(strUserID).Fields(2).value objFISERVcls.Terminate
Set objReport = Application.BasicFunctions.GetCrystalReport("Account:Account BI Data Report")
With objReport .DiscardSavedData .SetReportVariableValue("p_UserName",strUser) strFilter = "{C_ACCOUNTBIDATA.ACCOUNTID} = ('"&AcctID&"')" objReport.RecordSelectionFormula = strFilter End With
'This view should have a crystal report viewer on it Set objReportMV = application.MainViews.Add("Personal:CR_Viewer",0,False)
On Error Resume Next objReportMV.DetailsView.Script.ShowView objReport objReportMV.Caption = "Test" objReportMV.Maximize objReportMV.Show
Set objReport = Nothing
End Sub |
|
|
| |
| |
| |
|
Re: Can someone tell me how I would go about passing a value from saleslogix to a crystal report?
Posted: 03 Oct 08 2:01 PM
|
Stephen,
I have tried and tried, but I keep failing at this line: objReportMV.DetailsView.Script.ShowReport(objRDC)
I have also tried objReportMV.DetailsView.Script.Show(objRDC) with no luck. After debuggin I checked what .Script contained and I saw ShowReport() so I used it naturally and SLX and Visual studio says ShowReport() or Show() does not exist. It seems to me that something is missing with .DetailsView. I can't even expand it in VisualStudio until I throw it in a watch and manually write out: objReportMV.DetailsView.Script.
Here is my full code:
Sub ShowReport
Dim strUser 'get username Dim objFISERVcls Set objFISERVcls = New Fiserv_Palombo_Default
Dim strUserID strUserID = application.BasicFunctions.CurrentUserID
objFISERVcls.Initialize strUser = objFISERVcls.GetUserInfo(strUserID).Fields(2).value objFISERVcls.Terminate
Dim AcctID AcctID = Application.BasicFunctions.CurrentAccountID
Dim tblFilter tblFilter = "{C_ACCOUNTBIDATA.ACCOUNTID}"
Dim objRDC Set objRDC = Application.BasicFunctions.GetCrystalReport("Account:Account BI Data Report")
With objRDC '.SetReportVariableValue "p_UserName", strUser .RecordSelectionFormula = tblFilter & " = '" & AcctID & "'"
End With
Dim strRepView strRepView = "account:c_bireportviewer"
Dim objReportMV Set objReportMV = Application.MainViews.Add(strRepView, 0, False)
objReportMV.Maximize objReportMV.Show Application.BasicFunctions.ProcessWindowMessages objReportMV.DetailsView.Script.ShowReport objRDC
Set objReportMV = Nothing Set objRDC = Nothing Set objFISERVcls = Nothing
End Sub |
|
|
| |
|
Re: Can someone tell me how I would go about passing a value from saleslogix to a crystal report?
Posted: 03 Oct 08 2:44 PM
|
Harendra,
Thanks for the reply, but I don't see how to use your method: GlobalReportController.CrystalReport...
Using RDC I have already defined my report using Application.BasicFunctions.GetCrystalReport. .SQLQueryString is there as an option, but I'm already filtering my report properly. I've tested the above without using a mainview and just using export functions and the report exports seemlesly the way I need it however this report needs to be displayed to the user and not exported at that time.
My original question was just to pass a parameter or variable to the crystal report, but not to filter the records based on the parameter or variable. This variable is only going to be displayed in the report using a parameter field in Crystal. Imagine I have a perfect report.. It pulls great, but I need the current user name displayed at the very bottom to show who pulled the report. |
|
|
|
Re: Can someone tell me how I would go about passing a value from saleslogix to a crystal report?
Posted: 03 Oct 08 7:26 PM
|
Hi RJ,
You know that you can just create your own Form and drop a Crystal Viewer object onto it (say you call the control "RV") then you can have some code on Open to view your report - something like:
RV.ReportSource = RDC RV.ViewReport
Where RDC is an RDC object containing your report parameters.
You can also do stuff like:
Dim Sect Set Sect = RDC.Sections.Item(2) Sect.AddTextObject "Printed By " & Application.BasicFunctions.SystemInfoFor("Username") & " on " & Now, 1, 1
To add text.
Stephen www.slxmaster.com
|
|
|
|
Re: Can someone tell me how I would go about passing a value from saleslogix to a crystal report?
Posted: 06 Oct 08 9:35 AM
|
Stephen, thank you so much. I used a little variation of your help and what I've learned about RDC and came up with this:
Sub AXFormShow(Sender)
frmReportViewer.Caption = "Caption
Dim objRDC Set objRDC = application.BasicFunctions.GetCrystalReport("Account:AccountBI")
Dim AcctID AcctID = Application.BasicFunctions.CurrentAccountID
Dim tblFilter tblFilter = "{C_ACCOUNTBI.ACCOUNTID}"
Dim strUser 'get username Dim objcls Set objcls = New Palombo_Default
Dim strUserID strUserID = application.BasicFunctions.CurrentUserID
objcls.Initialize strUser = objcls.GetUserInfo(strUserID).Fields(2).value objcls.Terminate
With objRDC .RecordSelectionFormula = tblFilter & " = '" & AcctID & "'" .EnableParameterPrompting = False .ParameterFields(1).AddCurrentValue(strUser) End With
objRPT.ReportSource = objRDC objRPT.ViewReport
Application.BasicFunctions.ProcessWindowMessages
Set objcls = Nothing Set objRDC = Nothing End Sub
All is working perfect! |
|
|
| |
|