you probably saw this one coming...
if i use a pre-built roster with a Direct
contact type, emails get sent on alarm as expected. we need to filter alarm emails on a per-asset basis, so i whipped up the following script, which generates the correct object for the email engine:
users = system.user.getUsers('TurboUsers') #<-- blank = default user source
currentAsset = str({displayPath})
alarmEmailList = []
for user in users:
userRoles = user.getRoles()
username = user.get('username')
if ('spanky' in userRoles) and user.getContactInfo():
userContactInfo = str(user.getContactInfo()[0])
# gives 'email: floop@doop.ca'. yes. a string.
if 'email' in userContactInfo:
emailEntry = {}
if userFunctions.singleUserFunctions.canUserDo(currentAsset, username, 'isNotified'):
userEmail = userContactInfo.replace('email: ', '')
emailEntry['username'] = username
emailEntry['email'] = [userEmail]
alarmEmailList.append(emailEntry)
return alarmEmailList
so this will generate and return a list of dicts, as expected and required:
[
{ 'email': 'floop@doop.ca', 'username': 'floop' },
{ 'email': 'spang@glarn.io', 'username': 'spang' }
]
emails will not be sent.
so i tried modifying it based on an old working script:
alarmEmailList.append(userEmail)
alarmRoster = { 'email': [alarmEmailList] }
return [alarmRoster]
emails do not get sent.
so, in a fit of pique, i hardcoded the damn thing:
return [{ 'email': ['floop@doop.ca', 'spang@glarn.io']}]
emails do not send.
can someone determine what i am missing? for all i can deduce, this builds the correct structure and returns it. several times. but it flat out does not send anything. the last one is the one that really stumped me: hardcoded = nothing. whut the ?