# Custom Alarm Shelve Button with Alarm Status Table

**URL:** <https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572>\
**Category:** Ignition\
**Tags:** ignition80, vision\
**Created:** [April 18, 2022, 9:05pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572 "2022-04-18T21:05:27Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 18, 2022, 9:05pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/1 "2022-04-18T21:05:27Z")

</div>

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](https://docs.inductiveautomation.com/display/DOC80/system.alarm.shelve)).

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [April 18, 2022, 9:17pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/2 "2022-04-18T21:17:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 18, 2022, 9:25pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/3 "2022-04-18T21:25:19Z")

</div>

I tried exactly as the example shows:

```auto
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

```auto
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'`

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [April 18, 2022, 9:37pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/4 "2022-04-18T21:37:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 18, 2022, 9:49pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/5 "2022-04-18T21:49:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [April 18, 2022, 10:09pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/6 "2022-04-18T22:09:11Z")

</div>

Where did you put this script?

And is the table populated when script is running?

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 18, 2022, 10:16pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/7 "2022-04-18T22:16:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [April 18, 2022, 10:17pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/8 "2022-04-18T22:17:08Z")

</div>

> [@amarks](#):
>
> `'Source '`

That trailing space and capital S might be a problem.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 18, 2022, 10:31pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/9 "2022-04-18T22:31:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [April 18, 2022, 10:46pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/10 "2022-04-18T22:46:04Z")

</div>

Try this

```auto
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.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 18, 2022, 11:31pm UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/11 "2022-04-18T23:31:27Z")

</div>

Seems to have worked. Thanks

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [April 19, 2022, 12:15am UTC](https://forum.inductiveautomation.com/t/custom-alarm-shelve-button-with-alarm-status-table/58572/12 "2022-04-19T00:15:29Z")

</div>

Happy to help. This is better:

```auto
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)

```
