Executing the example requires the following objects in the repository:
A time series database with the TSDB identifier.
A validation rule with the NEWVALRULE identifier created in the TSDB time series database. (See Creating a Validation Rule).
A workbook with the OBJ123 identifier created using the time series database with the TSDB identifier. The validation rule is applied to the data of this workbook.
Add links to the following system assemblies:
Ms.
Metabase.
Cubes.
Dimensions.
Create a form and add the following components to it:
UiErAnalyzer with the UiErAnalyzer1 identifier. Select the workbook with the OBJ123 identifier in the Object property of the component. If the Active property is set to False, set it to True.
LanerBox with the LanerBox1 identifier. Select the UiErAnalyzer1 object in the Object property of the component.
Button with the Button1 identifier. Below is the function which is executed on clicking the button:
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Mb: IMetabase;
RubrKey: Integer;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
DateSettings: IValidationDateSettings;
FilterSett: IValidationFilterSettings;
Level: IValidationLevel;
ComparisonValue: IValidationComparisonValue;
ValidExecSett: IValidationExecuteSettings;
Analyzer: IEaxAnalyzer;
ValidExecRun: IValidationExecRun;
DiagRep: IDiagnosticReport;
Begin
Mb := MetabaseClass.Active;
// Get a validation rule
RubrKey := Mb.GetObjectKeyById("TSDB");
ValidObj := Mb.ItemByIdNamespace("NEWVALRULE", RubrKey).Edit;
ValidFilter := ValidObj As IValidationFilter;
// Set start and end dates of rule calculation
DateSettings := ValidFilter.StartDateSettings;
DateSettings.DateOptions := ValidationDateOptions.DependsFromData;
DateSettings := ValidFilter.EndDateSettings;
DateSettings.DateOptions := ValidationDateOptions.DependsFromData;
// Set calendar level to calculate the rule
ValidFilter.Level := DimCalendarLevel.Year;
// Set threshold value for rule exceptions
ValidFilter.ExceptionsLimit := 500000;
// Set parameters for calculation of the rule
FilterSett := ValidFilter.Settings;
// Set the rule type
ValidFilter.Kind := ValidationDetailsKind.Level;
Level := ValidFilter.Details As IValidationLevel;
// Set conditions of the rule
ComparisonValue := Level.ComparisonValue;
ComparisonValue.ComparisonOperator := ValidationComparisonOperator.More;
ComparisonValue.Percentage := False;
ComparisonValue.Value1 := 100;
// Save changes in the rule
ValidObj.Save;
// Execute the rule in the loaded workbook
ValidExecSett := New ValidationExecuteSettings.Create;
Analyzer := UiErAnalyzer1.ErAnalyzer;
ValidExecSett.Laner := Analyzer.Laner;
ValidExecRun := ValidFilter.Execute(ValidExecSett);
DiagRep := New DiagnosticReport.Create;
DiagRep.Run := ValidExecRun;
DiagRep.EaxAnalyzer := Analyzer;
End Sub Button1OnClick;
After executing the example, on clicking the button, values greater than 100 are highlighted in red in the table.
See also: