# Calculated Alarming Roster Error

**URL:** <https://forum.inductiveautomation.com/t/calculated-alarming-roster-error/75784>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 30, 2023, 3:04pm UTC](https://forum.inductiveautomation.com/t/calculated-alarming-roster-error/75784 "2023-06-30T15:04:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cameron\_Nickle](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cameron\_Nickle](https://forum.inductiveautomation.com/u/Cameron_Nickle)\
**Post date:** [June 30, 2023, 3:04pm UTC](https://forum.inductiveautomation.com/t/calculated-alarming-roster-error/75784/1 "2023-06-30T15:04:42Z")

</div>

Hi all,

I'm working on a simple calculated roster to get my feet wet with how these system work. I'm running a simple named query with no parameters and trying to use that data to create a simple user to send an email. The email system does work but the roster itself is not working as I think it is.

Error:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/e/cea2904b0de2b5486cce28ba436766b6ae186061.png)

Code:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/8/38eaa4833c914444d9da15b1b9ac785bd85e3636.png)

I'm sure its a simple error, I'm just not familiar with alarming.

Thank you,

Cam

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 30, 2023, 4:16pm UTC](https://forum.inductiveautomation.com/t/calculated-alarming-roster-error/75784/2 "2023-06-30T16:16:37Z")

</div>

The error comes from the very first line. You're trying to call `event.name`, which is a string.

That said, once that's fixed, you still won't get what you expect.  
The loop is returning a single user, which I doubt is what you want.  
You need to return after the loop is complete, not inside it.

---

<div class="post-metadata">

**Author:** ![Cameron\_Nickle](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cameron\_Nickle](https://forum.inductiveautomation.com/u/Cameron_Nickle)\
**Post date:** [June 30, 2023, 4:33pm UTC](https://forum.inductiveautomation.com/t/calculated-alarming-roster-error/75784/3 "2023-06-30T16:33:17Z")

</div>

Hi,

I was able to make it work with the following code:

```auto
def calculateRoster(event, builder):
	# get the alarm name property
	alarmName = event.getName()
	
	if alarmName in ["Diagnostic Alarm"]:
		# return an empty list so no one will be emailed
		return []
	
	else:
		# get user information from the database
		
		#data = system.db.runNamedQuery("get_AlarmInformation")				
		data = system.db.runPrepQuery("SELECT wa_users.username, wa_user_ci.contact_type, wa_user_ci.contact_value FROM wa_user_ci INNER JOIN wa_users ON wa_users.id = wa_user_ci.user_id")
		
		
		for row in data:
			if row['contact_type'] == "email":			
				builder.username(row['username']).email([row['contact_value']]).add()
		userList = builder.build()
		return userList

```

However, I'd rather have it run the named query so all my queries are encapsulated in one location. If I un-comment the namedQuery I get this error:

```auto
org.python.core.PyException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Project name required for script execution: the Gateway Scripting Project is not set.
at org.python.core.Py.JavaError(Py.java:547)
at org.python.core.Py.JavaError(Py.java:538)
at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:192)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:552)
at org.python.core.PyObject. __call__ (PyObject.java:461)
at org.python.core.PyObject. __call__ (PyObject.java:465)
at org.python.pycode._pyx2755.calculateRoster$1(:20)
at org.python.pycode._pyx2755.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyFunction.function ___call__ (PyFunction.java:474)
at org.python.core.PyFunction. __call__ (PyFunction.java:469)
at org.python.core.PyFunction. __call__ (PyFunction.java:459)
at org.python.core.PyFunction. __call__ (PyFunction.java:454)
at com.inductiveautomation.ignition.alarming.pipelines.blocks.NotificationBlock.getEvaluatedRosterFromScript(NotificationBlock.java:233)
at com.inductiveautomation.ignition.alarming.pipelines.blocks.NotificationBlock.sendNotification(NotificationBlock.java:131)
at com.inductiveautomation.ignition.alarming.pipelines.blocks.NotificationBlock$EvaluationContext.onEvaluate(NotificationBlock.java:374)
at com.inductiveautomation.ignition.alarming.pipelines.blocks.AbstractEvaluationContext.evaluate(AbstractEvaluationContext.java:78)
at com.inductiveautomation.ignition.alarming.pipelines.SingleThreadAlarmPipeline$QueueEvaluator.run(SingleThreadAlarmPipeline.java:187)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Project name required for script execution: the Gateway Scripting Project is not set.
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.interpretWithOptionalProject(GatewayDBUtilities.java:476)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:391)
at jdk.internal.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:190)
... 17 common frames omitted

```

---

<div class="post-metadata">

**Author:** ![Cameron\_Nickle](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cameron\_Nickle](https://forum.inductiveautomation.com/u/Cameron_Nickle)\
**Post date:** [June 30, 2023, 5:24pm UTC](https://forum.inductiveautomation.com/t/calculated-alarming-roster-error/75784/4 "2023-06-30T17:24:54Z")

</div>

As alarm notifications are in the gateway scope you have to pass the project path as a parameter in your named query.

Along with converting it to a PyDataset so that you can iterate through it

data = system.db.runNamedQuery("WorkingAlone\_V2","get\_AlarmInformation")  
data = system.dataset.toPyDataSet(data)
