# Java array error

**URL:** <https://forum.inductiveautomation.com/t/java-array-error/3298>\
**Category:** General Discussion\
**Created:** [September 19, 2011, 10:57am UTC](https://forum.inductiveautomation.com/t/java-array-error/3298 "2011-09-19T10:57:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamJaimes](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@SamJaimes](https://forum.inductiveautomation.com/u/SamJaimes)\
**Post date:** [September 19, 2011, 10:57am UTC](https://forum.inductiveautomation.com/t/java-array-error/3298/1 "2011-09-19T10:57:28Z")

</div>

I did a script to make an ‘acknowledge all’ button:

`p = 0
while p < 22:	
	table = event.source.parent.getComponent("Alert Summary")
	alerts = table.alerts
	alertSys = alerts.getValueAt(p,"System")
	alertPath = alerts.getValueAt(p,"Path")
	alertState = alerts.getValueAt(p,"State Name")
	system.alert.acknowledgeAlert(alertSys,alertPath,alertState)
	p += 1`

it runs perfectly except for this error:

[code] Traceback (innermost last):

File “event:actionPerformed”, line 5, in ?

java.lang.ArrayIndexOutOfBoundsException: 0

java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: 0  
[/code]

How can I solve this?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 19, 2011, 12:38pm UTC](https://forum.inductiveautomation.com/t/java-array-error/3298/2 "2011-09-19T12:38:44Z")

</div>

Hi Sam. Welcome to the forums!

I have to say that you confused me. Don’t worry about that, because my wife says it’s not hard to do! 😆

But doesn’t the Alert summary table already have an Acknowledge All button?

EDIT: In the meantime, try this:

```auto
table = event.source.parent.getComponent("Alert Summary")
alerts = table.alerts

for row in alerts: 
   alertSys = alerts.getValueAt("System")
   alertPath = alerts.getValueAt("Path")
   alertState = alerts.getValueAt("State Name")
   system.alert.acknowledgeAlert(alertSys,alertPath,alertState)
```

I think what is happening is that your script assumes that there is always 22 rows in the dataset. This may or may not be true, depending on how you have the component set up. Using the for row method should work, regardless of the number of rows in the dataset.

Also, ‘table’ is getting re-initialized on every iteration of the loop. I don’t know if that was intentional or not, but most times you should be able to set it just once.

---

<div class="post-metadata">

**Author:** ![SamJaimes](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@SamJaimes](https://forum.inductiveautomation.com/u/SamJaimes)\
**Post date:** [September 21, 2011, 7:35am UTC](https://forum.inductiveautomation.com/t/java-array-error/3298/3 "2011-09-21T07:35:40Z")

</div>

Thanks!

Your wife was right, it was not so hard. The problem was about the array’s range. I will try using alerts dataset properties. However, the script was incorrect.
