Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira - Can the change in value of scripted field be interpreted as an event?

Andrew Zimmerman
Community Champion
February 19, 2019

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!

1 answer

1 accepted

2 votes
Answer accepted
Nic Brough -Adaptavist-
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.
February 19, 2019

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?

Andrew Zimmerman
Community Champion
February 19, 2019

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?

Nic Brough -Adaptavist-
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.
February 20, 2019

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"

Like Andrew Zimmerman likes this
Andrew Zimmerman
Community Champion
February 20, 2019

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

Suggest an answer

Log in or Sign up to answer