Script: (function () { // 'message' must be the variable name for the test message myObject =JSON.parse(message); var data = []; for (i = 0; i < myObject.values.length; i++){ var newValues = []; var value = myObject.values[i]; var name = value.id; var q; if (value.q) q = 192; else q = 0; var dt= new Date(); newValues.push({ datetime: dt, value: value.v, numericQuality : q }); var records = []; records.push( { datetime: dt, value: "psi", numericQuality : 10 }); var props = []; props.push( { propertyName: "EngUnit", records: records } ); var annotations = []; annotations.push( { user: "grover", annotationTime: dt, Annotation: "Hello There" } ); data.push({ tagName: name, values: newValues, properties: props, annotations: annotations}); } var result = { data: data } return JSON.stringify(result, null, 4); })(); Test Message: { "timestamp": 1640188770477, "values": [ { "id": "Simulation Examples.Functions.Ramp1", "v": 51, "q": true, "t": 1640188770305 }, { "id": "Simulation Examples.Functions.Ramp2", "v": 180, "q": true, "t": 1640188770305 }, { "id": "Simulation Examples.Functions.Ramp3", "v": 104, "q": true, "t": 1640188770305 }, { "id": "Simulation Examples.Functions.Ramp4", "v": 940, "q": true, "t": 1640188770305 } ] }