Custom Alarm Shelve Button with Alarm Status Table

How do I script a button to shelve selected alarms from an Alarm Status Table? The example shown for system.alarm.shelve() in the manual does not work (system.alarm.shelve - Ignition User Manual 8.0 - Ignition Documentation).

Can you please post your code using the </> button. Might be something wrong in your script, and can’t know unless we see.

I tried exactly as the example shows:

table = event.source.parent.getComponent('Alarm Status Table')

rows = table.selectedRows

data = table.data

if len(rows)>0:
	sourcePaths = [str(data.getValueAt(r,'Source ')) for r in rows]
	system.alarm.shelve(path = sourcePaths, timeoutMinutes = 5)

but get the error com.inductiveautomation.factorypmi.application.com' object has no attribute 'selectedRows'

I also tried

table = event.source.parent.getComponent('Alarm Status Table')

rows = table.selectedAlarms

data = table.data

if len(rows)>0:
	sourcePaths = [str(data.getValueAt(r,'Source ')) for r in rows]
	system.alarm.shelve(path = sourcePaths, timeoutMinutes = 5)

and get 'com.inductiveautomation.factorypmi.application.com' object has no attribute 'data'

I believe the issue you are facing is due to the fact that you are using an alarm status table component instead of a table component. The documentation you provided states:

This example assumes that data has been loaded into a table ("Table") from system.alarm.queryStatus, and it shelves the selected alarms for 5 minutes.

Ok, I’ve updated my title. Still unsure how to go about shelving alarms selected in an Alarm Status Table.

I’ve also tried to print the selected alarms dataset, just to see what it looks like, but it doesn’t seem to print to the console.

Where did you put this script?

And is the table populated when script is running?

Table and button are in the same root container, right next to eachother. Script is attached to the button’s on actionPerformed behavior. Table is populated, and a few alarms are selected.

That trailing space and capital S might be a problem.

The script doesn’t even make it that far, and I was just following the example in the manual.

Try this

results = event.source.parent.getComponent('Alarm Status Table').selectedAlarms
resultsLength = results.getRowCount()

for i in range(resultsLength):
	almPath = str(results.getValueAt(i,'source'))
	system.alarm.shelve(path = almPath, timeoutMinutes = 5)

Also, i know there’s a better way to do this i hope a better scripter will come point out a better way and my mistakes (;

Edit: oh and it would be a good idea to check if there are selected alarms first, like the documentation does.

Seems to have worked. Thanks

Happy to help. This is better:

results = event.source.parent.getComponent('Alarm Status Table').selectedAlarms
resultsLength = results.getRowCount()
paths = []

if resultsLength > 0:
	for i in range(resultsLength):
		almPath = str(results.getValueAt(i,'source'))
		paths.append(almPath)
	system.alarm.shelve(path = paths, timeoutMinutes = 5)