Customs Functions for MetricFunctionLibrary


I am trying to create a custom function for the Metric Expression Engine.
I added these two files:


type HelperLibrary mixes MetricFunctionLibrary {
   * bla bla
  * @param value
   *        input value
   * @return absolute value of the input value.
  compareStringTs: function(strA: Timeseries, strA: Timeseries): Timeseries js server


function compareStringTs(strA, strB){
    var dataA =
    var dataB =

    var result = []

    for(var i=0;i<dataA.length;i++){
        if (dataA[i] == dataB[i]){
        else {result.push(0);}

    return Timeseries.makeNorm(NormTimeseriesDoubleSpec.make({
    start: strA.start(),
    end: strA.end(),
    interval: strA.interval(),
    data: result

When Trying to evaluate:

var results1 = BusinessCreditApplication.evalMetrics({
        expression: "compareStringTs(BorrowerDomicileCountry, BorrowerDomicileCountry)",
        id: "test_BCA_5",
        start: "2016-12-31",
        end: "2017-02-01",
        interval: "DAY"

I get the following error: wrapped org.mozilla.javascript.EcmaError: TypeError: Cannot call method “data” of undefined (HelperLibrary_compareStringTs.js#2)↵↵ at org.mozilla.javascript.ScriptRuntime.constructError↵ …↵ at c3.engine.action.RhinoActionEngine.callFunk (↵↵ from ScbHelperLibrary_compareStringTs.js, line 2↵ 1 (function(global$) {var $ScbHelperLibrary$functions = (funct…↵ > 2 var dataA =↵ 3 var dataB =↵

The input metrics have been tested and returns correct results.
Why are the two inputs received by the functions Undefined?

Thank you



First issue I can see is that the evalMetrics API takes an EvalMetricsSpec argument which only has the plural fields ids and expressions, not id and expression. Can you update that and confirm you’re getting the same error?