I have a scripted field (created in ScriptRunner) called Total Completed Story Points on Epics that rolls up the Story Points for all the child Stories that are in a Completed Status.
I added a Jira Automation rule to update another custom field when the Total Completed Story Points field value changes.
The rule is never triggered, even though when I complete a Story the parent Epic has the Total Completed Story Points field value updated.
I'm guessing that Jira Automation only triggers when a specified field is manually edited, and not when the value of the field is changed by a script. Is this the case? Is there some way to trigger Jira Automation on a field when the value is changed by a ScriptRunner script?
You won't be able to do this. Scripted fields do not change values in the same way that other custom fields do, Jira is not actually directly aware that they change. So Automation, Listeners and the issue history don't get anything when they do.
You will need to look at the script behind the field. What does that do? You'll need your automation or listener to pick up something that would make the calculated value change.
If, for example, your script says "scripted field = field X + field Y", then your automation or listener should be looking for changes of X or Y.
Thanks for the info, @Nic Brough -Adaptavist-
The custom field adds up the Story Points fields for all the child Stories under the Epic. So this value changes when a child Story is Resolved or Reopened.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried putting a listener on the Issue Resolved and Issue Reopened events so I can catch the Stories changing state, and then update the parent Epic's custom field, but this listener also doesn't trigger.
Any ideas what I could be doing wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, I think I have found it.
Your script appears to be for adding up story points from links on to a field on the current issue.
But not just adding - accumulating. When issue-123 is resolved, add the story points to Epic-456's running total. i.e. total completed story points += linked sp
Nothing wrong with that, but it's not going to work with a scripted field. The value of the scripted field is being recalculated by the script currently running. So there's no value in it at the beginning of the script, which Jira has to assume means "0".
You could do it in a scripted field, by parsing what you need out of all the issue histories, but that's a lot of code and a lot of load.
I would delete the scripted field, and start again with a custom number field. Do not put that on any create/edit/transition screens so the humans can't interfere with it, and run the same calculation code you have for the scripted field, adding the "write to custom field" code you'll need.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not quite, I think. Ignore the listener code. I gave up on this because I couldn't get it to trigger. The scripted field script actually runs through each child story to sum the Story Points from zero every execution, so it's not cumulative.
I'm not sure if it is the right thing to do, but I got it to work by just adding code to the Total Story Points scripted field to also update the Actual Effort custom field. So I'm updating 2 fields with one scripted field. Doesn't feel right to me, but it works.
I'm not sure what triggers a custom field to calculate but, strangely, I need to refresh the tab displaying the parent Epic twice to see the updated Actual Effort value.
Here's the Total Completed Story Points script:
Does this look alright? Any suggestions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It looks right to me.
You will always have to refresh a page to pick up that a field has been changed outside the current screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nic.
I take your expert opinion as validation :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Craig Goulden,
Are the changes to the scripted field being shown in the issue history of the ticket? Either way, it looks like this may be a known issue!
Thanks,
Kian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, that looks like the problem to me. The scripted field change in the parent doesn't appear in the history.
I'm working with Adaptavist.
The first suggestion was to avoid Jira Automation and just use a listener on the scripted field. This didn't work for what I'm guessing is the same reason; the listener isn't triggered by the scripted field value change.
The next suggestion is to create a listener on the child story, and in the listener update the parent epic.
I'm still working on getting this to work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.