Forum Discussion
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");
- cjhoward185 years agoEmployee
Hi @Henchway
If you have the key
$content
mapped in your response document, that will be considered the response body, and the rest of the key/value pairs are treated as response headers. - asharifian5 years agoEmployee
Hi @Henchway,
If you are referring to having a SnapLogic triggered task respond with a custom HTTP header value, then these are the following scenarios:
- If you’re using the ground URL on a groundplex, then it’s possible by having the custom value go to the $[‘content-type’] variable in a Mapper snap. Ensure your Mapper snap has a Binary output and that it’s unlinked.
The $content variable within the Mapper will contain the response body so ensure that’s there if necessary.
- If you’re using the cloud URL (whether it be via a groundplex or cloudplex), this is currently not possible and only standard HTTP headers can be returned in that case.
Thanks,
Ali