calculated-field-controller
Test Script expression
Execute the Script expression and return the result. The format of request:
{
"expression": "var temp = 0; foreach(element: temperature.values) {temp += element.value;} var avgTemperature = temp / temperature.values.size(); var adjustedTemperature = avgTemperature + 0.1 * humidity.value; return {\"adjustedTemperature\": adjustedTemperature};",
"arguments": {
"temperature": {
"type": "TS_ROLLING",
"timeWindow": {
"startTs": 1739775630002,
"endTs": 65432211,
"limit": 5
},
"values": [
{ "ts": 1739775639851, "value": 23 },
{ "ts": 1739775664561, "value": 43 },
{ "ts": 1739775713079, "value": 15 },
{ "ts": 1739775999522, "value": 34 },
{ "ts": 1739776228452, "value": 22 }
]
},
"humidity": { "type": "SINGLE_VALUE", "ts": 1739776478057, "value": 23 }
}
}
Expected result JSON contains "output" and "error".
Available for users with 'TENANT_ADMIN' authority.
post/api/calculatedField/testScript
Request body
{"stackTrail":"components:schemas:JsonNode","oasType":"schema","type":"unknown","description":"A value representing the any type (object or primitive)","example":{}}
Example request
{}Response
OK
{"stackTrail":"components:schemas:JsonNode","oasType":"schema","type":"unknown","description":"A value representing the any type (object or primitive)","example":{}}
Example response
{}