Send email with ScriptRunner post function not evaluating to true

Greetings,

We've just begun evaluating ScriptRunner with our Jira 7.3.0 instance. We want to send a custom email when an issue is created and contains 'Sev 1' or 'Sev 2' in the 'Severity' field. 

We've setup the post-function w/ScriptRunner's built in script, and every time we use the Preview function, it evaluates to "false" even though the key issue we're previewing with has 'Sev 2' as the value for the 'Severity' field. 

This is the Condition block of the ScriptRunner integration:

issue.issueType.name == 'Incident'
cfValues['Severity'] == ['Sev 1', 'Sev 2']

This is the Body Text:

Dear ${issue.reporter?.displayName},

The ${issue.issueType.name} ${issue.key} $issue.summary classified as ${cfValues['Severity']} requires your attention.

Description: $issue.description

Status: $issue.status.name 

When hitting the preview button, the body text pulls in all of the correct values. What I don't understand is why the condition consistently evaluates to false. When I create a new issue with a Severity value of Sev 1 or Sev 2, the email is never generated/received.

1 answer

 

 

cfValues['Severity']?.value in ['Sev 1', 'Sev 2']

 

The first line will have no effect whatsoever, you need to && it with the second line if that's your intention:

issue.issueType.name == 'Incident' &&
  cfValues['Severity']?.value in ['Sev 1', 'Sev 2']

Jamie, 

Thanks for the quick reply. Updating the script to what you provided resulted in the Preview functionality evaluating the condition to true. So that's the good news!

The bad news is that my custom email was never sent/received. 

In the Post Function tab, the green checkmark appears with the date/time stamp of the creation of my test item.

Here are my 3 Post Functions for this transition:

  1. Creates the issue orignally.
  2. Fire a Issue Created event that can be processesd by the listeners.
  3. ScriptRunner workflow function - Send a custom email (condition apply). 

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Thursday in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

881 views 4 5
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