Once you have retrieved the report and the parameter you wish to modify, you may modify the parameter in one of two ways:
If the parameter already has a current value, you may change it directly. Note that parameter values are changed differently depending on whether or not they are ranged or discrete. To determine whether a parameter is ranged or discrete, use IsRangeValue Property and IsSingleValue Property respectively. You should also check the parameter value's type using the ValueType Property.
Result = InfoStore.Query("Select Top 1* From CI_INFOOBJECTS Where" +
"SI_PROGID = 'CrystalEnterprise.Report'");
ReportObject = Result.Item(1).PluginInterface("");
Param = ReportObject.ReportParameters.Item(1).CurrentValues.Item(1);
//Check if a string value is being used.
if (Param.Valuetype=6) Param.Value = "Some String";
//Check if a string value is being used.
This example deletes all of the parameter's current values and adds new ones.
Result = InfoStore.Query("Select Top 1* From CI_INFOOBJECTS Where" +
"SI_PROGID = 'CrystalEnterprise.Report'");
ReportObject = Result.Item(1).PluginInterface("");
CurrentValues = ReportObject.ReportParameters.CurrentValues;
NewSingleParam = ReportObject.ReportParameters.CreateSingleValue();
ReportObject.ReportParameters.Item(1).CurrentValues.Add (NewSingleParam);
NewRangeParam = ReportObject.ReportParameters.CreateRangeValue();
NewRangeParam.FromValue = "A";
ReportObject.ReportParameters.Item(1).CurrentValues.Add (NewRangeParam);
Once the report parameters have been modified, you may schedule the report in the usual manner. For more information on this, see Lesson 3d: Scheduling reports.
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |