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.
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")
]
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?
Or perhaps you are confused by jython's automatic conversion of NetBeans-style getter methods into implicit properties? (Which is why .contactInfo works.)