Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,082
Community Members
 
Community Events
176
Community Groups

JMWE Email Issue Post-function return email address on checkbox selection

I am attempting to use the JMWE Email Issue Post-function to email a notification to multiple users based on whether a checkbox value is selected. I currently have the following within the Email addresses Groovy box:

if (issue.getAsString("customfield_13571") == 'user1') {return 'user1@email.com'}
if (issue.getAsString("customfield_13571") == 'user2') {return 'user2@email.com'}
if (issue.getAsString("customfield_13571") == 'user3') {return 'user3@email.com'}
else {return 'other@email.com'}

When I test this it will pass but will not actually return anything regardless of what checkbox value I have selected.

Any help would be greatly appreciated!

2 answers

1 accepted

1 vote
Answer accepted

Hi @Josh Pulda ,

Ok, I understand now.

Assuming you still want to send to one email address per checked checkbox, the code would then be:

<%= issue.get("customfield_13571").collect{
switch(it.value) {
case "user1": return "email1@acme.com";
case "user2": return "email2@acme.com";
case "user3": return "email3@acme.com";
default: return "email4@acme.com";
}
}.unique().join(",") %> 

 

Thanks, @David Fischer _Appfire_

This works perfectly!

1 vote

Hi @Josh Pulda 

for checkboxes, the value test is different. Please check the "Issue Fields" help tab at the bottom of the editor, then select your checkboxes field to see how to test the field value.

But in your case you seem to want to return multiple email addresses, one per selected checkbox, so the code will be different.

Also, the Email addresses option expects a Groovy template, not script:

image.png

Finally, are user1@email.com etc. email addresses of actual Jira users? If so, you should instead use the "Users from script" option with a script that returns one or more usernames instead of email addresses.

Let me know which case it is, and I'll provide the corresponding code.

Hi David, 

Thanks for clarifying. I am attempting to return an email address because I would like it to be that of a distribution list email outside of JIRA. To better explain my logic, I should have updated the checkbox values to be set to a generic group name such as group1, group2, etc. If the checkbox selection is equal to that of 'group1' then return a hard-coded distribution list email that corresponds to that group.

Hope this makes sense!

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events