Kevin - I think what you build is similar to what we need on our side. I am using groovy for scripting.
Now struggling with how to create the body for the format I need. Here is the latest groovy that works but everything is inside for loop. I need to create more sections or objects.
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("CHRQuoteDataSet");
//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 inputData = new JsonSlurper().parseText(inputMap.get("CHRQuoteDataSet"));
//def inputOrders = inputData.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.documentNumber=member.F55RR01_DOCO;
newObj.customerCCode=member.F55RR01_55CCOD;
newObj.companyKey=member.F55RR01_KCOO;
newObj.country=member.F55RR01_CTR;
newObj.originCtr=member.F55RR01_OTCTR;
newObj.originZip=member.F55RR01_OTZIP;
newObj.shipDate=member.F55RR01_SHIPDT;
newObj.weightUnit = "Pounds";
newObj.freightClass=member.F55RR11_UWUM;
newObj.deliveryNo=member.F55RR01_DELN;
newObj.shipmentWeight=member.F55RR11_WGTS;
newObj.orderType=member.F55RR01_DCTO;
newObj.freightClass=member.F55RR11_55FRCL;
newObj.UKID=member.F55RR01_UKID;
newObj.postalcode=member.F55RR01_ADDZ;
//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;
}
Here is an example of JSON i need so I can pass into the api. Not sure how to get items:, origin: text before the brackets.
{
"items": [
{
"description": "AG 1100+ SWITCH FOR METAL PAN",
"freightClass": 70,
"actualWeight": 22,
"weightUnit": "Pounds",
"volumeUnit": "CubicFeet",
"declaredValue": 686.4,
"packagingCode": "CAS",
"productCode": "AG 1100+ SWITCH FOR METAL PAN",
"productName": "AG 1100+ SWITCH FOR METAL PAN",
"isStackable": false,
"nmfc": 70,
},
],
"origin": {
"locationName": ".",
"address1": "12128 New Berlin Rd",
"city": "Jacksonville",
"stateProvinceCode": "FL",
"countryCode": "US",
"postalCode": 32226
},
"destination": {
"locationName": "CARRIER SOUTHEAST 1850",
"address1": "1711 CORPORATION PKY",
"city": "RALEIGH",
"stateProvinceCode": "NC",
"countryCode": "US",
"postalCode": 27604
},
"shipDate": "2024-03-13",
"customerCode": "C8598560",
"transportModes": [
{
"mode": "LTL"
},
{
"mode": "Parcel"
}
]
}