You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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?
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.