TSService.checkCalcFormula

Syntax

openRub (wbk: PP.TS.WbkDocument, checkFormula: Object, callback: PP.Delegate);

Parameters

wbk. Sets workbook value.

checkFormula. Formula check metadata.

callback. Sets handler for operation execution end.

Description

The checkCalcFormula method sends a query to server to check correctness of the formula specified in the calculator.

Comments

The response is obtained by the callback function.

Example

To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component).

// Set formula metadata
checkFormula = 
{
  "formula": {
    "k": 0,
    "kind": "Deterministic",
    "method": {
      "deterministic": {}
    },
    "exprs": {
      "its": {
        "it": [
          {
            "id": "input",
            "innerText": "@0@ * 0.1",
            "k": 0,
            "terms": {
              "its": {
                "it": [
                  {
                    "k": 0,
                    "id": "",
                    "source": {
                      "kind": "VarSource",
                      "varSource": {
                        "kind": "LanerSerie",
                        "serie": {
                          "k": 3
                        }
                      }
                    },
                    "lag": 0
                  }
                ]
              }
            }
          }
        ]
      }
    },
    "calendarLevel": "Quarter"
  }
};
// Create a callback function that receives response
var respT;
callB = function(args, resp) {
  valid = resp.Response.GetWbkMdResult.meta.action.checkFormula.valid;
  console.log(valid ? "Formula is set correctly" : "Formula is set incorrectly");
};
// Request server for formula correctness
tsService.checkCalcFormula(wbk, checkFormula, callB);

After executing the example the console displays response about correctness of the specified formula.

See also:

TSService