I am struggling with this code as I am unable to correctly split the JSON data. The error message I keep encountering is: TypeError: Cannot read property "cu_id" from undefined.
Here is a snippet of the JSON data (since it's too large to display entirely, but the remaining part is consistent)
{"started":"2022-01-15T12:56:08.197","finished":"2022-01-15T12:56:08.207","action":"RECEIVE","status":"SUCCESS","username":"sciarlo","subject":"340382659301954864","object":"10834376","result":"Created lots 5265995","trace_id":"LC3tS16A","properties":{"arrival_id":"ARR-98fc5b2b-cad2-4033-9bff-3af5cd779946","cu_id":"10834376","cu_quantity":"62","freshness_date_format":"NONE","load_carrier_barcode":"340389301954864","location":"3403826554864","purchase_orders":"366469","receive_type":"SSCC","temperature_zone":"AMBIENT",...
Below is the portion of the code causing issues:
var receiveActions = []
var latestTimestamp = receiveTab.getRange(2, 19).getValue();
var actionTime = new Date(outputArray[0].finished)
receiveTab.getRange(3, 19).setValue(actionTime);
for (var i in outputArray) {
var receiveAction = outputArray[i];
if (new Date(receiveAction.finished) > new Date(latestTimestamp)) {
var article = receiveAction.properties.cu_id;
var location = receiveAction.properties.location;
var temperatureZone = receiveAction.properties.temperature_zone;
var cuQuantity = receiveAction.properties.cu_quantity;
var tuQuantity = receiveAction.properties.tu_quantity;
var tuSize = cuQuantity/tuQuantity;
var timestamp = new Date(receiveAction.finished);
var user = receiveAction.username;
receiveActions.push([timestamp,user,temperatureZone,article,location,tuQuantity,tuSize])
}
}
Your assistance with this issue is greatly appreciated!