The following example creates a value and assigns it to a report.
privatebool CreateReportValue() { // Get report object by report code name ReportInfo report = ReportInfoProvider.GetReportInfo("MyNewReport"); // If report exists if (report != null) { // Create new report value object ReportValueInfo newValue = newReportValueInfo(); // Set the properties newValue.ValueDisplayName = "My new value"; newValue.ValueName = "MyNewValue"; newValue.ValueQuery = "SELECT COUNT(DocumentName) FROM CMS_Document"; newValue.ValueQueryIsStoredProcedure = false; newValue.ValueReportID = report.ReportID; // Save the report value ReportValueInfoProvider.SetReportValueInfo(newValue); returntrue; } returnfalse; }
The following example gets and updates a report value.
privatebool GetAndUpdateReportValue() {
// Get the report value ReportValueInfo updateValue = ReportValueInfoProvider.GetReportValueInfo("MyNewValue");
if (updateValue != null) { // Update the properties updateValue.ValueDisplayName = updateValue.ValueDisplayName.ToLower(); // Save the changes ReportValueInfoProvider.SetReportValueInfo(updateValue); returntrue; } returnfalse; }
The following example gets and bulk updates report values.
privatebool GetAndBulkUpdateReportValues() { // Prepare the parameters string where = "ValueName LIKE N'MyNewValue%'"; // Get the data DataSet values = ReportValueInfoProvider.GetValues(where, null); if (!DataHelper.DataSourceIsEmpty(values)) { // Loop through the individual items foreach (DataRow valueDr in values.Tables[0].Rows) { // Create object from DataRow ReportValueInfo modifyValue = newReportValueInfo(valueDr); // Update the properties modifyValue.ValueDisplayName = modifyValue.ValueDisplayName.ToUpper(); // Save the changes ReportValueInfoProvider.SetReportValueInfo(modifyValue); } returntrue; } returnfalse; }
The following example deletes a report value.
privatebool DeleteReportValue() {
// Get the report value ReportValueInfo deleteValue = ReportValueInfoProvider.GetReportValueInfo("MyNewValue");
// Delete the report value ReportValueInfoProvider.DeleteReportValueInfo(deleteValue); return (deleteValue != null); }