ValidationErrorsPanel.setValidation

Syntax

setValidation(state: Object, validId: String);

Parameters

state. Validation rule settings.

validId.  Validation moniker key.

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 ValidationErrorsPanel class named validationErrorsPanel (see ValidationErrorsPanel Constructor). First define an object with the settings that indicate the Missing Data validation rule type where missing values are detected within data, and also set exact start and end date of the data period to validate:

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
    }
};

Process the RequstMetadata event and apply validation rule settings defined above:

// Process the RequestMetadata event
validationErrorsPanel.RequestMetadata.add(function (sender, args) {
    console.log("Request metadata...");
});
// Specify validation rule settings
validationErrorsPanel.setValidation(state, "dfdff434!12");

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:

ValidationErrorsPanel