Purpose: Displaying object data into Liquid UI tableThis involves retrieving data from a given object and displaying it in a structured table format in Liquid UI. The table should show relevant information for each event entry, including fields such as Timestamp, Device ID, Temperature, and Alert status.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs-----------------------------------------------------------------------------------------------------------------------------------------------------------
Liquid UI Code:// Delete Image Containerdel("X[IMAGE_CONTAINER]");
// Instruction to perform the operation.comment([0,55], "Click the Pushbutton to retrieve data.");
// Calling the retrievedata function through a pushbuttonpushbutton([1,65],"@CF@Extract Data",{"process":retrievedata});
// Creating a LiquidUI table and adding columns to display the object data.table([1,1],[9,60],{"name":"taskTable","title":"Data Retrieve Table","rows":10,"rowselection":true});
column("Timestamp", {"table":"taskTable","size":20,"name":"z_timestamp",'readonly':true});
column("Device ID", {"table":"taskTable","size":25,"name":"z_deviceId",'readonly':true});
column("Temperature", {"table":"taskTable","size":5,"name":"z_temperature",'readonly':true});
column("Alert", {"table":"taskTable","size":5,"name":"z_alert",'readonly':true});
//Function to retrieve data from a Data Objectfunction retrievedata(){
var arrData = [];
for (var i = 0; i < objTaskEventList.results.length; i++) {
var g_timestamp = objTaskEventList.results
.event.timestamp;
var g_deviceId = objTaskEventList.results.event.deviceId;
var g_temperature = objTaskEventList.results.decode.temperature.sample;
var g_alert = objTaskEventList.results.decode.temperature.alert;
var arrRow = [g_timestamp,g_deviceId,g_temperature,g_alert];
arrData.push(arrRow);
}
for(var idx = 0; idx < arrData.length; idx++){
taskTable.z_timestamp[idx]=arrData[idx][0];
taskTable.z_deviceId[idx]=arrData[idx][1];
taskTable.z_temperature[idx]=arrData[idx][2];
taskTable.z_alert[idx]=arrData[idx][3];
}
}
//Data Object
var objTaskEventList =
{
"results": [
{
"type": "beacon",
"event": {
"id": "a308c3f0-bf50-4180-a315-6f5f91a5decc",
"timestamp": "2024-10-25T15:39:21Z",
"deviceId": "59b0e8c2-87c4-4109-9b4c-bead14ed1f97",
"data": {
"format": "beacon",
"id": "DLN233301440",
"rssi": -46,
"value": "17.59"
}
},
"analytics": {
"tenant": "f9339f76a7f1143dc30f587a46e09a6e",
"recordedTimestamp": "2024-10-25T15:39:37.618Z",
"resourceId": "db8597cd-6176-415c-bff4-90583a77f9a6",
"timestamp": "2024-10-25T15:39:21Z",
"meta": {
"data": {
"taskId": "3aabc8ea-00f1-4780-9256-817f024d0bd3",
"task_alarm": false,
"notes": "",
"assetIds": []
}
},
"coordinates": {
"global": {
"lat": 37.522003,
"lng": -121.953835
}
}
},
"decode": {
"temperature": {
"sample": 17.59,
"deviation": 0.0,
"format": "celsius",
"taskId": "3aabc8ea-00f1-4780-9256-817f024d0bd3",
"alert": false
}
}
},
{
"type": "beacon",
"event": {
"id": "b32a6d08-cffc-4fd3-b1bb-06a3218a1c2c",
"timestamp": "2024-10-25T15:38:51Z",
"deviceId": "59b0e8c2-87c4-4109-9b4c-bead14ed1f97",
"data": {
"format": "beacon",
"id": "DLN233301440",
"rssi": -46,
"value": "17.59"
}
},
"analytics": {
"tenant": "f9339f76a7f1143dc30f587a46e09a6e",
"recordedTimestamp": "2024-10-25T15:39:37.618Z",
"resourceId": "db8597cd-6176-415c-bff4-90583a77f9a6",
"timestamp": "2024-10-25T15:38:51Z",
"meta": {
"data": {
"taskId": "3aabc8ea-00f1-4780-9256-817f024d0bd3",
"task_alarm": false,
"notes": "",
"assetIds": []
}
},
"coordinates": {
"global": {
"lat": 37.522003,
"lng": -121.953835
}
}
},
"decode": {
"temperature": {
"sample": 17.59,
"deviation": 0.0,
"format": "celsius",
"taskId": "3aabc8ea-00f1-4780-9256-817f024d0bd3",
"alert": false
}
}
},
{
"type": "beacon",
"event": {
"id": "4d0357c7-5e57-49c8-b819-f22ba3210405",
"timestamp": "2024-10-25T15:38:21Z",
"deviceId": "59b0e8c2-87c4-4109-9b4c-bead14ed1f97",
"data": {
"format": "beacon",
"id": "DLN233301440",
"rssi": -46,
"value": "17.59"
}
},
"analytics": {
"tenant": "f9339f76a7f1143dc30f587a46e09a6e",
"recordedTimestamp": "2024-10-25T15:39:37.618Z",
"resourceId": "db8597cd-6176-415c-bff4-90583a77f9a6",
"timestamp": "2024-10-25T15:38:21Z",
"meta": {
"data": {
"taskId": "3aabc8ea-00f1-4780-9256-817f024d0bd3",
"task_alarm": false,
"notes": "",
"assetIds": []
}
},
"coordinates": {
"global": {
"lat": 37.522003,
"lng": -121.953835
}
}
},
"decode": {
"temperature": {
"sample": 17.59,
"deviation": 0.0,
"format": "celsius",
"taskId": "3aabc8ea-00f1-4780-9256-817f024d0bd3",
"alert": false
}
}
},
{
"type": "beacon",
"event": {
"id": "3c0cf20f-9c6e-4e4b-95d1-d3b0b8b60cc4",
"timestamp": "2024-10-25T15:37:51Z",
"deviceId": "59b0e8c2-87c4-4109-9b4c-bead14ed1f97",
"data": {
"format": "beacon",
"id": "DLN233301440",
"rssi": -46,
"value": "17.59"
}
},
"analytics": {
"tenant": "f9339f76a7f1143dc30f587a46e09a6e",
"recordedTimestamp": "2024-10-25T15:39:37.618Z",
"resourceId": "db8597cd-6176-415c-bff4-90583a77f9a6",
"timestamp": "2024-10-25T15:37:51Z",
"meta": {
"data": {
"taskId": "3aabc8ea-00f1-4780-9256-817f024d0bd3",
"task_alarm": false,
"notes": "",
"assetIds": []
}
},
"coordinates": {
"global": {
"lat": 37.522003,
"lng": -121.953835
}
}
},
"decode": {
"temperature": {
"sample": 17.59,
"deviation": 0.0,
"format": "celsius",
"taskId": "3aabc8ea-00f1-4780-9256-817f024d0bd3",
"alert": false
}
}
}
]
}