As the title says I was curious if it was possible to populate a power table from a script.
Essentially there is some data that I would like to manipulate before displaying it into the Power Table, and the easiest way that I can think of wouldn’t be through an SQL query, but rather a short script that can ensure that the data is what I expected it to be.
Would anyone know of a way that I can do this?
Sure, here is an example I stole from the manual…
headers = ["City", "Population", "Timezone", "GMTOffset"]
data = []
data.append(["New York", 8363710, "EST", -5])
data.append(["Los Angeles", 3833995, "PST", -8])
data.append(["Chicago", 2853114, "CST", -6])
data.append(["Houston", 2242193, "CST", -6])
data.append(["Phoenix", 1567924, "MST", -7])
tableData = system.dataset.toDataSet(headers, data)
event.source.parent.getComponent('Power Table').data = tableData
That shows you can write to a table via a script. You can run your SQL query in a script as well. Link in case you need it:
https://docs.inductiveautomation.com/display/DOC81/Queries+in+Scripting
2 Likes
Ah this is exactly what I was looking for!
Thank you very much!