Replacing script with mapper expression

Hi All,
I wanted to replace the javascript code with just mapper expression with input :
ipofscript
and the output is a string of 1300 characters each i.e ->‘filter’ is output which is having 1300 character limit when grouping the ouid (input) with some condition as shown below


This is the javascript code:
var impl = {
input: input,
output: output,
error: error,
log: log,

execute: function() {
    this.log.info("Executing Transform Script");
    i = 0;
    maxLength = 1300;
    var queryStr = "(";
    while (this.input.hasNext()) {
        try {
            i++;
            var doc = this.input.next();
            var tmpStr = "";
            if (queryStr != "(") {
                tmpStr += " or ";
            }
            tmpStr += "ou_id eq " + doc.get("ou_id");
            if (queryStr.length() + tmpStr.length() > maxLength || !this.input.hasNext()) {
                if (!this.input.hasNext()) {
                    queryStr += tmpStr;
                }
                queryStr += ")"
                var wrapper = new java.util.HashMap();
               // wrapper.put("MLL_Access_Token", doc.get("MLL_Access_Token"));
                wrapper.put("$filter", queryStr);
                this.output.write(doc, wrapper);
                queryStr = "(";
            } else {
                queryStr += tmpStr;
            }
            this.log.info("Transform Script finished");
        } catch (err) {
            var wrapper = new java.util.HashMap();
            wrapper.put("errorMsg", err);
            this.log.error(err);
            this.error.write(wrapper);
        }
    }
}

};

Any help is appreciated.

cc: @dmiller @koryknick @ptaylor @bojanvelevski @siwadon

Hi @rashmi,

Group the ids with a Group By or Gate.
Once you have all of the Ids in an array, use the following expression in a mapper:

'(ou_id eq ' + $group.join(' or ou_id eq ') + ')'

Let me know if this helps,
Bojan

1 Like

@bojanvelevski Thanks a lot!