Hi, I'm trying to create a listener with Script-Runner plug in.
When I change the "Epic Link" field of a story I wish it will update the story's "Fix Version"
according to the new Epic it was linked to.
I wrote the following script listener (listens to "Issue Updated" event) but it doesn't do anything.
I would greatly appreciate it if someone can point me to what's wrong with my script and/or correct it:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLinkManager
MutableIssue issue = (MutableIssue) event.issue
if(issue.issueType.name == "Story"){
def isEpicLinkChanged = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Epic Link"}
def issueLinkManager = ComponentAccessor.issueLinkManager
def issueManager = ComponentAccessor.issueManager
if(isEpicLinkChanged){
issueLinkManager.getInwardLinks(issue.getId()).each {IssueLink issueLink ->
if (issueLink.getIssueLinkType().getName() == "Epic-Story Link") {
Issue epicIssue2 = issueLink.getSourceObject()
issue.setFixVersions(epicIssue2.fixVersions)
issueManager.updateIssue(event.getUser(), issue, EventDispatchOption.ISSUE_UPDATED, false)
}
}
}
}
Hi,
There is an issue opened on Atlassian's JIRA (JSWSERVER-12299) that talks about that.
The problem is that when the Epic Link is changed no event is triggered, so it's not your fault.
Regards,
Marcos.
Thank you Marcos!
Is there any known workaround to change fields automatically when Epic Link field is changed? (I guess not, but asking just in case...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I don't know, I searched for something by I didn't find nothing.
Sorry about that.
Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @[deleted], @Marcos Sanchez,
Were you able to get this work? I am facing the same issue. Thanks for your help.
Regards,
Deepali Bagul
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.