cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

crystal viewer parameter loses value on navigation

cecilia_schultz
Explorer
0 Kudos
773

Using "SAP Crystal Reports runtime engine for .NET Framework (64-bit)" version 13.0.31.4010,

and the corresponding component for VS: "SAP Crystal Reports, version for Microsoft Visual Studio" version 13.0.31.4010.

The CR viewer is CrystalDecisions.Web, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304

My report has several string type parameters. One of these parameters (called p_stu_cnt) is passed to the report. This param is displayed in the 2nd page header of the report.

When the report is rendered, it shows its value fine (e.g. "100"), but when I navigate (say, go to the next page), the parameter loses its value in the report (shows "0").

Not surprisingly, if I export, say to PDF, the lost value appears int he exported output.

I found an article https://community.sap.com/t5/technology-q-a/navigation-in-crystal-viewer-with-parameters/qaq-p/10016... that suggested setting the ReuseParameterValuesOnRefresh property of the viewer to true (it was false by default). I have done this, but no luck resolving the issue.

The value of this parameter is passed from a string variable, which is prior set to the given dataset's table row count, i.e.

string mQualifyingStudentCount = dtResults.Rows.Count;

then later passed on to the report parameter like so:

string p_stu_cnt = mQualifyingStudentCount.ToString();
report.SetParameterValue("p_stu_cnt", p_stu_cnt);

 

The strange thing is that if I just hardcode of my variable and pass it on to the report param, then the value is not lost! i.e:

string p_stu_cnt = '123";
report.SetParameterValue("p_stu_cnt", p_stu_cnt);

 

Is this a bug??!!

I appreciate your help,

 

 

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

DonWilliams
Active Contributor
0 Kudos

This happens in a WEB app if you don't use sessions and postback:

1985571 - How to use sessions in web applications using the Crystal Reports viewer (the complete cod...

See if that resolves the issue.

If it's a desktop app then likely you are using Refresh() in your code which will remove the current values.

Oh and I suggest updating to SP 36, CR for VS is only supported in the latest SP, SP 31 had issues in the viewer:

https://help.sap.com/docs/SUPPORT_CONTENT/crystalreports/3354091173.html

 

cecilia_schultz
Explorer
0 Kudos
Hello Don, Thank you very much for the quick response. Article 1985571 you referred me to does not seem to be complete: what is the RAPPBasePage class the class "Reports" int he code is inheriting from? Also, the code int he article is saving crReportDocument in the session under the "Report" key. Is this key name specifically required? are you telling me that the cr viewer will look in the session with this key?
DonWilliams
Active Contributor
0 Kudos
RAPPBasePage is your application, loading the report using a session and the postback keeps the report in session so it doesn't lose the parameters. No Idea what the report key is you mentioned

Answers (2)

Answers (2)

DonWilliams
Active Contributor
0 Kudos

DonWilliams_0-1729622051987.png

 

DonWilliams
Active Contributor
0 Kudos

The sample I created in the KBA works perfectly.

What you need to do is think about your work flow...

For example, if you close the session the report is no longer valid so you have to go through the whole routine again including logging onto the data source and parameters. If all you want to do is change the parameter value passed then EnableParameterPrompt in the Viewer, the user will then see a Parameter box on the left side which they'll be able to refresh and choose a new value.

 

cecilia_schultz
Explorer
0 Kudos
Don, thank you very much for the assiatnce, but unfortunately, the previous version that I thought it was "good" was not complete. First, I had forgotten to clear the report from memory (report.Close() report.Dispose()). Second, because the code does not go thru the entire thing (loading the report, generating the data, setting the parameters, and finally saving the report in the session), when IsPostBack is true, it causes that a second time the report is run (with a different parameter), it has the same exact data, even though the param was different. This is not a workable solution. A different parameter means the dataset will be different. All is passed programatically thru a webform. Additionally I have 2 pages, the first one collects the input (once the user enters the parameter via input in the first page . When this occurs, the flow passes it to a second page where the dataset is generated (based on the given input passed from the previous page), and report rendered. The example provided in the KBA does not have parameters. Nevertheless, when all the process to render the report is byppassed because if the IsPostBack logic, then what you get is old data. This is only evident when you ran the reportt twice with 2 different inputs. Setting EnableParameterPrompt to true is not an option, all the input is already colelcted via a web form, the report parameters are set programatically form this input. Thank you.
DonWilliams
Active Contributor
0 Kudos
EnableParameterPrompt to true allows the Viewer to use a new parameter, otherwise it always uses the same one.
DonWilliams
Active Contributor
0 Kudos
Your code is unreadable, use the more button and sellect paste code and select C#