How to convert issue links into Parent/Child links


アトラシアン コミュニティをご利用ください。


プラットフォームについて: Server と Data Center のみ - この記事は、サーバーおよびデータセンター プラットフォームのアトラシアン製品にのみ適用されます。


The information on this page relates to custom development via a third-party app in Jira Applications. Consequently, Atlassian Support cannot guarantee the provision of any support for the steps described on this page as custom development and third-party apps are not covered under Atlassian Support Offerings. Please be aware that this material is provided for your information only and that you use it at your own risk.

If you need any help with altering the script or are running into execution issue, we advise to reach out to the Atlassian Community.



As part of the adoption of Advanced Roadmaps, projects that were using issue links to define hierarchy relations will have to use the Parent Link field so they become nicely visible in Advanced Roadmaps plans. 


Execute this Groovy script in the ScriptRunner's development console. Note that the JQL and issue links names will have to be changed accordingly. Follow the code comments for more info. 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.getIssueManager()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

// edit this query to suit
def query = jqlQueryParser.parseQuery("project = PORTPC and type =\"Program Epic\" and issueLinkType = \"breakes down into\"")
def searchService = ComponentAccessor.getComponent(SearchService.class)

def results =, query, PagerFilter.getUnlimitedFilter())

//log.debug("Total issues: ${}")

results.getResults().each {documentIssue ->

	def issue = issueManager.getIssueObject(

	// Get issue links
	issueLinkManager.getInwardLinks( {issueLink ->
		// Edit issue link name here
		if ( == "Break Down") {
			def linkedIssue = (MutableIssue) issueLink.sourceObject
			def parentLinkField = customFieldManager.getCustomFieldObjectByName("Parent Link")
			if( == "Epic" && linkedIssue.getCustomFieldValue(parentLinkField) == null)

    			log.warn(issue.key + " is linked to " + linkedIssue.key) 
    			def parentLinkFieldType = parentLinkField.getCustomFieldType()
    			def newParentLink = parentLinkFieldType.getSingularObjectFromString(issue.key)
				linkedIssue.setCustomFieldValue(parentLinkField, newParentLink)
    			issueManager.updateIssue(user, linkedIssue, EventDispatchOption.ISSUE_UPDATED, false) 

最終更新日 2021 年 7 月 16 日


Powered by Confluence and Scroll Viewport.