Forums

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

How to get issue key of source issue during an issue split

Chris P_ June 9, 2020

I'm trying to build a listener that on a create event will check if they issue was created via the split function from the backlog so that I can then copy over custom fields.

This is necessary as the split tool only copies over native JIRA fields so missing a bunch of our custom ones that that normal clone tool does. Unfortunately the clone tool is cumbersome to use if you want to split large stories up into 6-7 stories, size them & schedule them. 

Currently I'm stuck not able to get the original key so no way to start getting those values to copy over. I can only get the event key or the epic key, both pretty useless.

I could probably achieve this through a post-function in the workflow... but then it'll only work for that 1 workflow and we have dozens of teams across a lot of projects, a listener would allow me to enable it everyone.

 

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueFieldConstants

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def fieldManager = ComponentAccessor.fieldManager

def issue = event.issue


// Get the original issue's ID so we can pull values from it during the split
issueLinkManager.getInwardLinks(issue.id).each {issueLink ->
if(!issueLinkManager.getInwardLinks(issue.getId())*.issueLinkType.name.contains('split from')){

// None of the object picks seem to work
def getSourceObject = issueLink.getSourceObject()
def getDestinationObject = issueLink.getDestinationObject()
def linkedIssues = issueLinkManager.getInwardLinks(issue.id)


log.info("getSourceObject: " + getSourceObject)
log.info("getDestinationObject: " + getDestinationObject)
log.info("issue key: " + issue.key)
log.info("linkedIssues: " + linkedIssues)

}
}

0 answers

Suggest an answer

Log in or Sign up to answer