Forum Discussion
bojanvelevski
5 years agoValued Contributor
Sorry, I missed that information.
We tried with script as below. it works in design mode but not when we call ultra tasks. When we call ultra tasks the script snap doesnt provide any output
execute : function () {
this.log.info(“Executing Transform Script”);
var outDoc = new LinkedHashMap();
var inDoc=null;
var items = new ArrayList();
var i=0;
while (this.input.hasNext())
{
try {
// Read the next input document, store it a new LinkedHashMap, and write this as an output document.
// We must use a serializable Java type liked LinkedHashMap for each output instead of a native
// JavaScript object so that downstream Snaps like Copy can process it correctly.
inDoc = this.input.next();
i=i+1;
items.add(inDoc);
outDoc.put("index", i);
if ((!this.input.hasNext()) || (this.input.hasNext()==false))
{
outDoc.put("data", items);
this.output.write(inDoc, outDoc);
}
}
catch (err) {
var errDoc = new LinkedHashMap();
errDoc.put("error", err);
this.log.error(err);
this.error.write(errDoc);
}
}
this.log.info("Script executed");
- Aleksandar_A3 years agoContributor III
Hi @Rahul,
You can split the issues array by using JSON Splitter [JSON Splitter Doc] with the following settings.
Let me know if this helps you.
BR,
Aleksandar.