ExpressionService.setExpression

Syntax

setExpression(args: Object, callback: PP.Delegate|Function, errCallback: PP.Delegate|Function);

Parameters

args. Operation arguments. An object must contain the following fields: reportOdId - express report moniker; reportType - report type; transfType - transformer type; transfKey - transformer key; serieKey - series key; terms - indicates whether terms are obtained; if the argument is set to True, the added terms are returned; isValid - indicates whether added terms are checked; if the argument is set to True, terms are checked for correctness; formulaString - string view of formula; newTermsParams - array of new term parameters; position - position where new terms are inserted (if the argument is set to -1, terms are not added to expression).

callback. Callback procedure.

errCallback. Callback procedure on error.

Description

The setExpression method requests for adding terms for expression.

Example

To execute the example, the HTML page must contain the TransformDialog component named dialog (see Example of Creating the TransformDialog Component). Get a service of expression and add handlers for the GetTerms and GetTermsErr events. Send a query to get terms from dimension element to expression:

// Get service of expressions
PP.Object.defineProps(PP.Ufe.Ui.TransformDialog, 'ExpService', True);
PP.Object.defineProps(PP.Ufe.Ui.TransformDialog, 'transformations', True);
var expService = dialog.getExpService();
// Add a handler to get terms by service of expressions
expService.GetTerms.add(function(sender, args) {
    console.log("Terms are obtained");
});
// Add a handler of error on getting terms by service of expressions
expService.GetTermsErr.add(function(sender, args) {
    console.log("Error getting terms");
});
// Get dimension element terms for expression
var myArgs = {
    isValid: True,
    position: 0,
    reportOdId: expressBox.getSource().getOdId().id,
    reportType: "Eax",
    terms: True,
    transfType: "Calc",
    transfKey: dialog.gettransformations().getTransformations()[0].k,
    newTermParams: [{
        n: "tag",
        v: "eax.sel"
    }, {
        n: "D_SEP",
        v: "30000"
    }]
};
expService.setExpression(myArgs);

As a result the console displays a message about getting terms:

Terms are obtained

 

Send a query to to get terms with incorrect transformer key:

// Get dimension element terms for expression
var myArgs = {
    isValid: True,
    position: 0,
    reportOdId: expressBox.getSource().getOdId().id,
    reportType: "Eax",
    terms: True,
    transfType: "Calc",
    transfKey: "key",
    newTermParams: [{
        n: "tag",
        v: "eax.sel"
    }, {
        n: "D_SEP",
        v: "30000"
    }]
};
expService.setExpression(myArgs);

As a result the console displays a message about error getting terms:

Error getting terms

See also:

ExpressionService