vbansal
Member
How to pass the output from data request to custom request (Groovy Script)?
I have a data request over a business view with multiple records. How do I pass the output from DR to custom request scripted in Groovy. When running testing the custom request with test value in input works fine. I could be missing a simple mapping being my 1st attempt.
Here is the groovy script
import com.oracle.e1.common.OrchestrationAttributes;
import java.text.SimpleDateFormat;
import groovy.json.*;
HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();
//Input is the full output of the data request
String dataSetIn = (String)inputMap.get("DataSetIn");
//create an object out of it
def jsonSlurper = new JsonSlurper();
def object = jsonSlurper.parseText(dataSetIn);
//get the record set
def dataset = object.fs_DATABROWSE_V55RR01J.data.gridData.rowset;
def newDataSet = [];
for(def member : dataset) {
//create a new object for the resulting data set with the new date values
def newObj = [:]
newObj.freightClass=member.F55RR11_55FRCL;
newObj.actualWeight=member.F55RR11_WGTS;
newObj.weightUnit = "Pounds";
//add to new output array
newDataSet.push(newObj);
}
//create a json string from the new data set
String newDataSetJson = JsonOutput.toJson(newDataSet);
//set that to the array variable defined in the custom
returnMap.put("GridData", newDataSetJson);
return returnMap;
}
When I copy the output manually in test value input I get correct results in test output.
Screen for Orchestrator which doesn't work when called one after the other -
I have a data request over a business view with multiple records. How do I pass the output from DR to custom request scripted in Groovy. When running testing the custom request with test value in input works fine. I could be missing a simple mapping being my 1st attempt.
Here is the groovy script
import com.oracle.e1.common.OrchestrationAttributes;
import java.text.SimpleDateFormat;
import groovy.json.*;
HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();
//Input is the full output of the data request
String dataSetIn = (String)inputMap.get("DataSetIn");
//create an object out of it
def jsonSlurper = new JsonSlurper();
def object = jsonSlurper.parseText(dataSetIn);
//get the record set
def dataset = object.fs_DATABROWSE_V55RR01J.data.gridData.rowset;
def newDataSet = [];
for(def member : dataset) {
//create a new object for the resulting data set with the new date values
def newObj = [:]
newObj.freightClass=member.F55RR11_55FRCL;
newObj.actualWeight=member.F55RR11_WGTS;
newObj.weightUnit = "Pounds";
//add to new output array
newDataSet.push(newObj);
}
//create a json string from the new data set
String newDataSetJson = JsonOutput.toJson(newDataSet);
//set that to the array variable defined in the custom
returnMap.put("GridData", newDataSetJson);
return returnMap;
}
When I copy the output manually in test value input I get correct results in test output.
Screen for Orchestrator which doesn't work when called one after the other -