Crystal Reports Dynamic Parameter Values

I have a crystal report with a dynamic parameter (e.g. linked to a COUNTRY table at some date). How can I programmatically get valid values ​​for this parameter (list of countries)? For static, I can get the default values ​​using:

ReportDocument rd = new ReportDocument(); rd.Load(reporthPath); rd.ParameterFields; // contains params with default values collections 

Dynamic parameters do not have elements in the DefaultValues ​​collection. I can get the existing connections for the report, but where can I get the connection between the connection and dynamic parameters?

+4
source share
3 answers

This cannot be done in Crystal Reports. It is better not to use a dynamic parameter field; they make your report unnecessarily slow. Instead, convert them to a static parameter, fill in the default values ​​from your code; it is much faster and you know what the accepted values ​​are.

+2
source

the answer above is incorrect - like Crystal Reports XI (at least where my information comes from), this is possible; see http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crtsktutorialsrdparametersdiscrete.htm , especially Part 2 (creating a report with parameters) and 5 Box ( displaying default options)

basically, the list of possible values ​​can be taken from the list of default values,

thanks,

MD-Tech

0
source

Improving existing answers a bit after starting this problem for grounding:

A ParameterField with a static list of values ​​has these values ​​as elements in the DefaultValues collection. The problem is that a ParameterField with a dynamic list does not have these values ​​pre-populated, and the API does not seem to have a mechanism for requesting them.

A workaround involves using a static list instead of a dynamic one, but there may be hundreds of valid values ​​that can change over time. If you remember that changing a report (s) is attractive, a dynamic list makes sense in this context.

In addition, using CrystalDecisions.ReportAppServer.DataDefModel.ParameterField shows the BrowseField property. BrowseField has TableAlias and Name properties that you can query using ADO.NET. However, BrowseField populated only for static parameters; when using a dynamic parameter, it is equal to zero. This is currently being documented as a “Correction Necessity” in the SAP Knowledge Base, article 2114469 .

So, once you get the name of the table and column, use ADO.NET to query the database and paste these values ​​into the DefaultValues collection of the Dynamic parameter. Consider using a naming convention for parameters to make this easier. Perhaps use a static parameter that is not used in the report to post information about your table and columns.

0
source

Source: https://habr.com/ru/post/1338849/


All Articles