script runner event listener condition not working on issue commented

I am trying to transition an issue only if comment is added via email listener and comment author is matching custom field on that issue.

So I have noticed when JIRA is listening for emails and adds a comment from email the issue commented event does not fire, so instead I use issue updated event. But this condition for some reason always evaluates to false and transition does not happen.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
def commentManager = ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(issue)
def approver
def author
if(getCustomFieldValue("Access Approver")){
    approver = getCustomFieldValue("Access Approver").toString()
}
author = comments.last().authorApplicationUser.toString()
if(author == approver){
    return true
}
else {
    return false
}

 

If I test the two field separately the returned string is the same so the condition should evaluate to true.

What am I doing wrong here

1 answer

0 vote
Vasiliy Zverev Community Champion Dec 12, 2015

Try to speed up debuging using this: https://answers.atlassian.com/questions/32982259.

First of all Check that "getCustomFieldValue("Access Approver").toString()" and "comments.last().authorApplicationUser.toString()" return the some value.

I have, I got another scripted field on the issue that compares them too and returns true if they match. So I know for sure that condition should return true.

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 Thursday in Jira

Meet the AUG leaders of Northern Virginia

@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....

154 views 5 9
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