It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
I am trying to dynamically set the recipient addresses based on the settings of a custom field ('Notification List', checkbox collection contains a list of department)
In the condition & configuration section, I have a
if ('Engineering' in cfValues['Notification List']*.value) { recipients = recipients + ",addr1@host.com" } if ('Purchasing' in cfValues['Notification List']*.value) { recipients = recipients + ",addr2@host.com" } mail.setTo(recipients)
So far so good, and working as expected
However, I'd like to pull from another custom field (ProjMgr) for one of the conditions
if ('Project Management' in cfValues['Notification List']*.value) { pm = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("ProjMgr") pmValue = issue.getCustomFieldValue(pm) recipients = recipients + "," + pmValue }
ProjMgr is User Picker type. In this case, I got the user id in pmvalue. How can I find the user's email address to construct the recipients list?
Maybe you try the following:
ger().getCustomFieldObjectByName("ProjMgr")
... pmValue = issue.getCustomFieldValue(pm) if (pmValue != null && !((String) pmVavlue).isEmpty()) { def user = ComponentAccessor.getUserManager().getUserByKey((String) pmValue); def mail = user.getEmailAddress() } .....
https://docs.atlassian.com/jira/7.1.7/com/atlassian/jira/component/ComponentAccessor.html
https://docs.atlassian.com/jira/7.1.7/com/atlassian/jira/user/util/UserManager.html
https://docs.atlassian.com/jira/7.1.7/com/atlassian/jira/user/ApplicationUser.html
Hope this helps!
Cheers,
Julian
pmValue returns "jackson.loong(jackson.loong)"
and
user returns null
I ended up using the following codes segment and seems to work
if ('Project Management' in cfValues['Notification List']*.value) { def pm = customFieldManager.getCustomFieldObjectByName("ProjMgr") if (pm != null) { def pmValue = issue.getCustomFieldValue(pm) if (pmValue != null && !((String) pmValue).isEmpty()) { def mailbox = ((ApplicationUser) pmValue).getEmailAddress() recipients = recipients + "," + mailbox } } }
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreAs a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.