# Example Project: Alarm Label on Left Bar problem

**URL:** <https://forum.inductiveautomation.com/t/example-project-alarm-label-on-left-bar-problem/2447>\
**Category:** Ignition\
**Created:** [December 22, 2010, 8:29pm UTC](https://forum.inductiveautomation.com/t/example-project-alarm-label-on-left-bar-problem/2447 "2010-12-22T20:29:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![noel](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@noel](https://forum.inductiveautomation.com/u/noel)\
**Post date:** [December 22, 2010, 8:29pm UTC](https://forum.inductiveautomation.com/t/example-project-alarm-label-on-left-bar-problem/2447/1 "2010-12-22T20:29:22Z")

</div>

The dynamic property for this label tries to run an app and I get a null exception error but I cannot figure out what is wrong. If there is a better way for the label to show when I have an alarm active I am game to try something else.

Dynamic Property Expression:  
runScript(“app.alert.activeAlerts()”, 1000)

APP defined as:  
def activeAlerts():  
import system  
return system.alert.queryAlertStatus(activeAndUnacked=1).rowCount

Error as follows:  
Exception: Error executing expression binding on  
Temporary.Root Container.AlarmLabel.NumAlarms  
caused by ExpressionException: Error executing script for runScript() expression:app.alert.activeAlerts()  
caused by Traceback (innermost last):  
File “expression:runScript”, line 1, in ?  
File “module:alert”, line 3, in activeAlerts  
java.lang.NullPointerException

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [December 22, 2010, 9:01pm UTC](https://forum.inductiveautomation.com/t/example-project-alarm-label-on-left-bar-problem/2447/2 "2010-12-22T21:01:01Z")

</div>

I think the `system.alert.queryAlertStatus(activeAndUnacked=1)` is returning null. You may want to do the following for you activeAlerts function:`def activeAlerts():
    import system
    ds = system.alert.queryAlertStatus(activeAndUnacked=1)
    if ds == None:
        return 0
    else:
        return ds.rowCount`Try that out and let us know.

---

<div class="post-metadata">

**Author:** ![noel](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@noel](https://forum.inductiveautomation.com/u/noel)\
**Post date:** [December 22, 2010, 9:20pm UTC](https://forum.inductiveautomation.com/t/example-project-alarm-label-on-left-bar-problem/2447/3 "2010-12-22T21:20:09Z")

</div>

Sadly the same result. Would you rather have the error copy?

Exception: Error executing expression binding on  
Temporary.Root Container.AlarmLabel.NumAlarms  
caused by ExpressionException: Error executing script for runScript() expression:app.alert.activeAlerts()  
caused by Traceback (innermost last):  
File “expression:runScript”, line 1, in ?  
File “module:alert”, line 3, in activeAlerts  
java.lang.NullPointerException  
java.lang.NullPointerException: java.lang.NullPointerException

Ignition v7.1.6 (b5739)  
Java: Sun Microsystems Inc. 1.6.0\_22

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [December 22, 2010, 9:43pm UTC](https://forum.inductiveautomation.com/t/example-project-alarm-label-on-left-bar-problem/2447/4 "2010-12-22T21:43:21Z")

</div>

Well it must be getting an error in our function. I will check it out. In the meantime you can wrap all of the code in your function into a try…except block like the following:`def activeAlerts():
    import system
    try:
        return system.alert.queryAlertStatus(activeAndUnacked=1).rowCount
    except:
        return 0`

---

<div class="post-metadata">

**Author:** ![noel](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@noel](https://forum.inductiveautomation.com/u/noel)\
**Post date:** [December 28, 2010, 1:42pm UTC](https://forum.inductiveautomation.com/t/example-project-alarm-label-on-left-bar-problem/2447/5 "2010-12-28T13:42:28Z")

</div>

Here are the details from the error:

#def activeAlerts():

# import system

# try:

# ds = system.alert.queryAlertStatus(activeAndUnacked=1)

# if ds == None:

# return 0

# else:

# return ds.rowCount

# except:

# return 0

def activeAlerts():  
import system  
return system.alert.queryAlertStatus(activeAndUnacked=1).rowCount

java.lang.Exception: Error executing expression binding on  
Temporary.Root Container.AlarmLabel.NumAlarms  
at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:56)  
at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.childInteractionUpdated(ExpressionPropertyAdapter.java:31)  
at com.inductiveautomation.ignition.common.expressions.functions.AbstractPollingFunction.actionPerformed(AbstractPollingFunction.java:80)  
at javax.swing.Timer.fireActionPerformed(Unknown Source)  
at javax.swing.Timer$DoPostEvent.run(Unknown Source)  
at java.awt.event.InvocationEvent.dispatch(Unknown Source)  
at java.awt.EventQueue.dispatchEvent(Unknown Source)  
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)  
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)  
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)  
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)  
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)  
at java.awt.EventDispatchThread.run(Unknown Source)  
Caused by: com.inductiveautomation.ignition.common.expressions.ExpressionException: Error executing script for runScript() expression:app.alert.activeAlerts()  
at com.inductiveautomation.ignition.common.expressions.functions.ScriptFunction.execute(ScriptFunction.java:57)  
at com.inductiveautomation.ignition.common.expressions.FunctionExpression.execute(FunctionExpression.java:69)  
at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:50)  
… 12 more  
Caused by: Traceback (innermost last):  
File “expression:runScript”, line 1, in ?  
File “module:alert”, line 13, in activeAlerts  
java.lang.NullPointerException

```
at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.toDataset(AbstractAlertUtilities.java:106)

at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.queryAlertStatus(AbstractAlertUtilities.java:40)

at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:310)

at org.python.pycode._pyx4.activeAlerts$1(<module:alert>:13)

at org.python.pycode._pyx4.call_function(<module:alert>)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyFunction. __call__ (PyFunction.java)

at org.python.core.PyObject.invoke(PyObject.java)

at org.python.pycode._pyx1.f$0(<expression:runScript>:1)

at org.python.pycode._pyx1.call_function(<expression:runScript>)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyCode.call(PyCode.java)

at org.python.core.Py.runCode(Py.java)

at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)

at com.inductiveautomation.ignition.common.expressions.functions.ScriptFunction.execute(ScriptFunction.java:54)

at com.inductiveautomation.ignition.common.expressions.FunctionExpression.execute(FunctionExpression.java:69)

at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:50)

at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.childInteractionUpdated(ExpressionPropertyAdapter.java:31)

at com.inductiveautomation.ignition.common.expressions.functions.AbstractPollingFunction.actionPerformed(AbstractPollingFunction.java:80)

at javax.swing.Timer.fireActionPerformed(Unknown Source)

at javax.swing.Timer$DoPostEvent.run(Unknown Source)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

```

java.lang.NullPointerException: java.lang.NullPointerException

```
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:394)
at com.inductiveautomation.ignition.common.expressions.functions.ScriptFunction.execute(ScriptFunction.java:54)
... 14 more

```

Caused by: Traceback (innermost last):  
File “expression:runScript”, line 1, in ?  
File “module:alert”, line 13, in activeAlerts  
java.lang.NullPointerException

```
at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.toDataset(AbstractAlertUtilities.java:106)

at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.queryAlertStatus(AbstractAlertUtilities.java:40)

at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:310)

at org.python.pycode._pyx4.activeAlerts$1(<module:alert>:13)

at org.python.pycode._pyx4.call_function(<module:alert>)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyFunction. __call__ (PyFunction.java)

at org.python.core.PyObject.invoke(PyObject.java)

at org.python.pycode._pyx1.f$0(<expression:runScript>:1)

at org.python.pycode._pyx1.call_function(<expression:runScript>)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyCode.call(PyCode.java)

at org.python.core.Py.runCode(Py.java)

at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)

at com.inductiveautomation.ignition.common.expressions.functions.ScriptFunction.execute(ScriptFunction.java:54)

at com.inductiveautomation.ignition.common.expressions.FunctionExpression.execute(FunctionExpression.java:69)

at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:50)

at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.childInteractionUpdated(ExpressionPropertyAdapter.java:31)

at com.inductiveautomation.ignition.common.expressions.functions.AbstractPollingFunction.actionPerformed(AbstractPollingFunction.java:80)

at javax.swing.Timer.fireActionPerformed(Unknown Source)

at javax.swing.Timer$DoPostEvent.run(Unknown Source)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

```

java.lang.NullPointerException: java.lang.NullPointerException

```
at org.python.core.Py.JavaError(Py.java)
at com.inductiveautomation.ignition.common.script.builtin.AbstractAlertUtilities.queryAlertStatus(AbstractAlertUtilities.java:42)
at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:310)
at org.python.pycode._pyx4.activeAlerts$1(<module:alert>:13)
at org.python.pycode._pyx4.call_function(<module:alert>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyFunction. __call__ (PyFunction.java)
at org.python.core.PyObject.invoke(PyObject.java)
at org.python.pycode._pyx1.f$0(<expression:runScript>:1)
at org.python.pycode._pyx1.call_function(<expression:runScript>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)
... 15 more

```

Ignition v7.1.6 (b5739)  
Java: Sun Microsystems Inc. 1.6.0\_22

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [December 28, 2010, 6:18pm UTC](https://forum.inductiveautomation.com/t/example-project-alarm-label-on-left-bar-problem/2447/6 "2010-12-28T18:18:34Z")

</div>

It looks like this is a bug that we have fixed in version 7.1.7. This issue is caused by calling system.alert.acknowledgeAlert() with empty string parameters. Once you do that, a null state gets introduced into memory and you start getting this error.

To fix this: stop the Ignition service, remove the .alerts file (C:\Program Files\Inductive Automation\Ignition\contexts\main.alerts), and then restart the service.
