Information Required for Alarm Pipeline

Exactly what information do I need to extract/supply for a calculated contact roster in the notification block? I can script getting all user info and compiling it fairy easily, but what I don’t know is what information is actually needed. I am using email notification but email is not one of the items in dictionary for user properties when I use system.user.getUser() I only get username, firstname, lastname, and a roles list.

Do I need to pass the email when I return the roster, or is only the username required and it’ll match the username to the email?

You must construct a valid enough object to notify - the only thing that really matters is the email (or other contact info). The entire point of the calculated roster type is that it doesn't rely on the user source "knowing" anything and allows you to notify any arbitrary set of contact information/retrieve that information from any source.

If you need more information on how to create a script that returns a list of dictionaries you can use this Notification Block | Ignition User Manual

Then how do I get the email from the existing users in a user source? I’m using a calculated roster to filter based on role(s).

Some possible inspiration in this thread:

Basically you interrogate the user source using the system functions then build that up into a response.

Put together, something like this:

def getUsersWithRole(userSource, role):
	return filter(
		lambda u: role in u.roles,
		system.user.getUsers(userSource)
	)

return [
	dict(
		username = user.get(user.Username),
		**{ci.contactType: ci.value for ci in user.contactInfo}
	)
	for user in getUsersWithRole("myUserSource", "administrator")
]

Right, that’s what I am doing but what I’m saying is that it appears that email is not included in the returned user info from the system function

image

Using your code, it does seem to successfully get the contact info but the contactInfo attribute seems to come out of nowhere. Why isn’t it displayed in the list?

It’s a User object, for whatever reason the contact info isn’t included in the repr method.

Contact Info is a nested list in the user object.

Would be nice if the documentation listed all attributes of the user object

The getContactInfo() method is documented. :man_shrugging:

Or perhaps you are confused by jython's automatic conversion of NetBeans-style getter methods into implicit properties? (Which is why .contactInfo works.)

fwiw this works, but runs into an issue if there’s more than one email