Creating a system.dataset in a Gateway Tag Change script

I have been trying to get alarm areas from the system.alarm.queryStatus script. I have it working with a button on a screen with a custom property dataset and a integer with the following code.

ds = event.source.parent.getComponent(‘Tabs’).Dataset
results = system.alarm.queryStatus(Source=[“Loadout”], State=[“ActiveUnacked”])
ds = results.getDataset()
event.source.parent.getComponent(‘Tabs’).LoadoutAlmActive = ds.rowCount

but I really need it to work whenever there is a new alarm in the system to check for any new alarms in this “area” of my tag folder structure. So I thought the best place for that would be a GateWay Event Tag change script looking at “[System]Gateway/Alarming/Active and Unacked” to run the following script, but I am having problems getting the queryStatus script into a dataset that is not a custom property dataset. What would be the best way to do this?

results = system.alarm.queryStatus(Source=[“Loadout”], State=[“ActiveUnacked”])
ds = system.dataset.toDataSet(results)

system.tag.write(test,ds.rowCount)

Thanks for any input.

I ended up figuring it out. Below was the code I used if anyone was interested.

system.tag.writeToTag(‘test’,0)

results = system.alarm.queryStatus(Source=[“Loadout”], State=[“ActiveUnacked”])
ds = results.getDataset()

for row in range(ds.rowCount):
for col in range(ds.columnCount):
system.tag.writeToTag(‘test’,ds.rowCount)

1 Like