Send email with ScriptRunner post function not evaluating to true

Fred Gruhn April 5, 2017

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

0 votes
Jamie Echlin _ScriptRunner - The Adaptavist Group_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 5, 2017

 

 

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']
Fred Gruhn April 5, 2017

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
TAGS
AUG Leaders

Atlassian Community Events