I have a report that i am creating and distributing using the system.report.executeAndDistribute function on a button press, but with our ever changing group of workers I am constantly updating the e-mail addresses. Is there a function to use an on-call roster since that can be changed with a few clicks?
From the manual
rosters = system.alarm.getRosters()
for key, values in rosters.iteritems():
# key is the roster name, values is a dict of usernames
print 'Roster', key, 'contains these users:'
for value in values:
print ' ', value
So that gets me all of the rosters and the names of the people in them. But how can I use that to create an e-mail list from a individual roster to use system.report.executeanddistribute?
No user source tpye was specified, but this assumes the users are in an internal user source.
rosterUsers = rosters['rosterName']
userInfo = system.user.getUsers('default')
contacts = [user.contactInfo for user in userInfo if user.get('username') in rosterUsers]
print contacts
2 Likes