Your code has a lot of problems.
Chiefly:
- You're not returning the contact infos as a list of possible contact infos
- You're not differentiating between SMS, email, or phone numbers, which you would want to do.
- You don't need to call
system.user.getUser
if you usesystem.roster.getRoster()
, which directly returnsUser
objects - Hardcoding in
default
to thesystem.user.getUser
function is also a bad idea. - You're returning in the wrong format anyways: you're returning something like:
[
{ "Maintenance Roster": [
{ "joe": [contactInfo] }
]
}
]
But you need to return a direct list of user-like objects; see the manual:
https://docs.inductiveautomation.com/display/DOC81/Notification+Block#NotificationBlock-Calculated
A generic mergeRosters
suitable for use in a calculated roster script would be something like this:
def mergeRosters(*rosterNames):
return [
dict(username = user.get(user.Username), **{ci.contactType: ci.value for ci in user.contactInfo})
for rosterName in rosterNames
for user in system.roster.getRoster(rosterName).users
]
return mergeRosters("day shift", "night shift")