Our goal is to have a listener that will run and ensure that if the FixVersion of a Story is updated, that it will trickle down the update to the associated subtasks.
I have made this change for a custom field we are using called "Team" as follows. When running, it will copy the Team field to its subtasks when updated. For some reason I can't get the same script to work for FixVersion - can someone help me?
Here is my script in use for event: issue updated for our custom field = 'Team' (adapted from Adaptavist documentation):
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Team"}
if (change) {
log.debug "Value changed from ${change.oldstring} to ${change.newstring}"
// your actions if the field has changed
def subtasks = event.issue.getSubTaskObjects()
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Team")
if (subtasks){
subtasks.each {it ->
def options = ComponentAccessor.getOptionsManager().getOptions(customField.getRelevantConfig(it))
((MutableIssue) it).setCustomFieldValue(customField, options.find {it.value == change.newstring})
ComponentAccessor.getIssueManager().updateIssue(event.user, ((MutableIssue) it), EventDispatchOption.DO_NOT_DISPATCH, false)
}
}
}
Thanks in advance.
Hi,
Can you also show the code you tried for "fix version"?
It's the same as above but with FixVersion in the place of 'Team'. but I realize this won't work as it is a core field and not a custom field - hence, why I'm asking what code should look like when referencing a core field. Any help would be much appreciated, thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FixVersions act and stored differently than drop down field, it's a collection.
You have a code solution here:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let me know if you managed to make it work for you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nir - not had a chance to try yet, but will keep you posted. Thanks for your assistance so far.
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.