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)
}
}
Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!
Start here