Hi there. My organization uses Jira Server v7.12.3 and we utilize the Adaptavist Scriptrunner add-on.
I'm working on a scripted Listener and trying to fire an event if a condition is true.
However, the event trigger I'd like to use is the change in value of a Script field. Is that possible? Can a change in Script field value be interpreted as an Issue Updated event? In which case, I could listen for a an Issue Updated event, add a scripted condition of "Script field value changed" (also, how do I do that?), and then fire the new event I want.
Thanks so much!
Interesting, but the short answer is "in most cases, no".
As a rough guide (this is technically not quite right, but is the easiest way to think of it), a scripted field is calculated when the issue is indexed. And sometimes more than once. The event that goes out when the field changes is actually due to other changes on the issue, it's not because the scripted field changes value.
Now, you could construct a scripted field that fires an additional event, but it's going to fire way too many of them to be useful, as the script is going to run many times, on almost any change. To get this down a bit, you'd then need to write a pile of code to work out what the old and new values of the field are to work out if an event actually needs to fire, and then there is a peculiarity in Jira in that it is still also going to fire between 1 and 4 events on those changes.
What you should use as the event trigger is the calculation - what might cause the scripted field to take a new value?
Got it. Thanks, @Nic Brough -Adaptavist- ! That makes sense. So, set a Listener for an event that would be triggered from the field edit that actually causes a change in value of the Script field. And then, condition that Listener to only fire a new event if true/upon specific values of the Script field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you should be looking for the cause of the field update, not the processes that occur afterwards.
Once you've found it though, I would not see any reason to fire a second event - you already know the field has changed (because the data it is built on has changed), so you can act directly on that, rather than trigger another event.
The exception to "avoid two events" is notifications - I'd still think about firing a second custom event for that, because otherwise I'd have to write my own email sending routine into "what happens when I detect a change"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Noted. Makes sense! And you're on to me. I was hoping to set up an event handling notification in Riada's Notification Assistant, based on the script field change.
Thanks for all the insight, @Nic Brough -Adaptavist-
-Andrew
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.