Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,360
Community Members
 
Community Events
184
Community Groups

ScriptRunner - why doesn't Listener adhere to Conditions?

Using the Adaptavist ScriptRunner for Jira Plugin, I want to test 2 conditions to allow an email to be sent.  Both conditions rely on checking values of custom fields.

Specifically, the one line I have in my Condition section is:

(cfValues['Reported by'] != null) && (cfValues["Customer"] != "xyz")

I know the fields are populated correctly because when I run the Preview mechanism to see what my email looks like, the validation step that tests the Condition is returning true or false correctly based on different issues I throw at it.

However, I've already seen where an issue that tested with a false condition was still sent out.  My concern is that warning in the Preview mode that states ".......note that for listeners the condition can't normally be tested".

What does 'normally' mean in this context?   Is there any way to have the Condition function as expected here?

Thanks!

1 answer

0 votes
Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 15, 2017

The note about listeners indicates that you can't reliably test a listener on something like an IssueUpdated event. Many conditions rely on things like comparing the current value of a custom field to the value it's being changed to. Those conditions only make sense when the event is firing, not on an issue in stasis. For your use case, that doesn't seem to apply.

As I'm reading your condition, it says, Only send the email if both of the following are true:

The 'Reported by' custom field is not null
The Customer custom field does not equal the string 'xyz'
If that's not what you intend, then you may simply need to rewrite the condition.

If you can reliably reproduce the issue, there are a few things I would check:

1. Does using the custom field manager instead of cfValues work?

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager
def reportedBy = customFieldManager.getCustomFieldObjectByName("Reported By")
def customer = customFieldManager.getCustomFieldObjectByName("Customer")
issue.getCustomFieldValue(customer) != 'xyz' && issue.getCustomFieldValue(reportedBy) != null

2. What is the specific configuration of your listener? What events is it firing on?
3. Is there anything specific that you need to do to reproduce the issue? Like, is the problem only occurring in a particular project?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events