ValidationRulesPanel.setValidation

Syntax

setValidation(state: Object, validId: String, cls: PP.Mb.MetabaseObjectClass, newValidation: Boolean);

Parameters

state. Validation rule settings.

validId. Key of the validation rule moniker.

cls. Object class in the metabase.

newValidation. Indicates if the validation is executed for the first time. If this validation is executed for the first time, this parameter must be True, otherwise it is False.

Description

The setValidation method defines settings of a workbook validation rule.

Comments

After the method execution the workbook shows a dialog box that contains validation rule settings.

Example

Executing this example requires an instance of the ValidationRulesPanel class named validationRulesPanel (see ValidationRulesPanel Constructor). Process the RequstMetadata event, set Missing Data validation rule type that finds missing values within data, and also exact start and end dates of data period to validate:

// Process the RequestMetadata event
validationRulesPanel.RequestMetadata.add(function (sender, args) {
    console.log("Request metadata...");
});
var state = {
    "obInst": {
        "obDesc": {
            // Determine rule name
            "n": "New validation rule",
        }
    },
    "details": {
        "missingData": {
            // Treat missing data inside data
            "type": PP.TS.ValidationMissingDataType.InData
        }
    },
    // Set the Missing Data rule type
    "kind": "MissingData",
    // Specify exact date as a period start
    "startDateSettings": {
        "DateOptions": PP.TS.ValidationDateOptions.SpecificDate,
        "date": "2012-04-12", // Period start date
        "lag": 2
    },
    // Specify exact date as a period end
    "endDateSettings": {
        "DateOptions": PP.TS.ValidationDateOptions.SpecificDate,
        "date": "2012-05-12", // Period end date
        "lag": 3
    }
};
// Determine filtering object class in metabase
var cls = PP.Mb.MetabaseObjectClass.KE_CLASS_VALIDATIONFILTER;
// Specify validation rule settings
validationRulesPanel.setValidation(state, "dfdff434!12", cls, False);

After executing the example the Validation Rule dialog box is shown in the workbook. Type of this rule is Missing Data, missing values are detected within data, exact start date of the period to check is 12.04.2012, exact end date is 12.05.2012:

When the RequestMetadata event is fired, the browser console displays an appropriate notice:

Request metadata...

See also:

ValidationRulesPanel