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?
Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events