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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

671 views 3 11
Read article

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