SAP Knowledge Base Article - Public

1805366 - How to retrieve a single ‘Default Value’ for a parameter in a Crystal report using Crystal Reports .NET SDK?

Symptom

How to retrieve a single ‘Default Value’ for a parameter in a Crystal report using Crystal Reports .NET SDK?

Environment

  • Visual Studio 2008 / Visual Studio 2010
  • Crystal Reports 2008 / Crystal Reports for Visual Studio 2010

Resolution

  • Currently, there is an API available in Crystal Report for Visual Studio 2010 Service Pack 3 .NET SDK to access the single value which is set as a ‘Default value’ in parameter properties.
  • Refer to below snapshot. 

 

  •  Single Default value.JPG
  • Code to get the Default Value:

    private void getDiscreteValues(CrystalDecisions.ReportAppServer.DataDefModel.ISCRParameterField paramfield)
    {
        string textBox1 = String.Empty;
        string name = paramfield.Name;
        int currValCount = paramfield.InitialValues.Count;
        int defValCount = paramfield.DefaultValues.Count;

        if (defValCount > 0) //this parameter has default values
        {
            foreach (ParameterFieldDiscreteValue discreteDefaultVal in paramfield.DefaultValues)
            {
                MessageBox.Show("Discrete default value1 " + discreteDefaultVal.Value.ToString());
                if (discreteDefaultVal.Description != null)
                {
                    discreteDefaultVal.Description.ToString();
                        MessageBox.Show("Discrete description value " + discreteDefaultVal.Description.ToString());
                }

               // This is the new API to get the Default value
                foreach (ParameterFieldDiscreteValue CurrentInitialVal in paramfield.InitialValues)
                { // Always only going to be 1
                    MessageBox.Show("Default Value: " + CurrentInitialVal.Value.ToString());
                }

            }
        }
        Else

 

Keywords

KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports, developer version for Microsoft Visual Studio

Attachments

Single Default value.JPG