Send email based on Custom Field ID

I want to be able to have a number of check boxes within the Issue create page, with these to include what teams will need to be involed with this issue;

Teams Involved:

Team1
Team2
Team3
Team4

So when the issue is created, if any of those checkboxes have been checked an email is sent to that team in addition. I tried using the builtin script runner but I wasn't able to get this working, I know the custom field ID of the Teams Involved field, I just need help creating the script to run this.

Thanks

1 answer

1 accepted

I assume you have seen this.

So I am guessing you have problems with condition then?

So wouldnt it be:

cfValues["Team Name:"]?.getValue() != "Team1"

Hope this helps

Ok, so my settings are as follows:

Builtin Script Runner - Send a custom email

Condition: cfValues["Teams Involved:"]?.getValue() != "Team1"

Result: java.lang.NullPointerException: Cannot invoke method getId() on null object

 

Forgot that checkbox is different, Jamie has answered pretty well in here

Also to note that the condition should be TRUE to make the script to run (like running email) so in your example, any name other than Team1 would send the email.

Hope this helps!

So I've set this up as suggested, and when I select Preview I get the following;

Condition The condition evaluated to true (note that for listeners the condition can't normally be tested)

Then I select Run and I get the following;

Result: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.atlassian.jira.event.issue.IssueEvent@7ab5f6cf[issue=IS-3753,comment=<null>,worklog=<null>,changelog=<null>,eventTypeId=1,sendMail=true,params={},subtasksUpdated=false]' with class 'java.lang.String' to class 'com.atlassian.jira.event.issue.IssueEvent'

Where IS-3753 is the test ticket, for which the value of the condition is true.

So I've set this up as suggested, and when I select Preview I get the following;

Condition The condition evaluated to true (note that for listeners the condition can't normally be tested)

Then I select Run and I get the following;

Result: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.atlassian.jira.event.issue.IssueEvent@7ab5f6cf[issue=IS-3753,comment=<null>,worklog=<null>,changelog=<null>,eventTypeId=1,sendMail=true,params={},subtasksUpdated=false]' with class 'java.lang.String' to class 'com.atlassian.jira.event.issue.IssueEvent'

Where IS-3753 is the test ticket, for which the value of the condition is true.

do you have screenshot? i t seems like you are adding another code fro issue event?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,831 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot