Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 5 Next »

(tick) Jira allows import of Jira issues and subtasks via CSV.

(tick) Jira allows import of default Jira links via CSV.

(error) Hidden links types such as epic links or asset relation links cannot be imported with a single CSV import.

Workaround 1: 2 Imports and V-Lookup

(as recommended by Atlassian Community)

  1. Import issues without relation links.

  2. Export imported issues with their issue keys and summary.

  3. Use excel V-Lookup to merge issue keys into original csv file for every row and for the links to be imported (see docu).

  4. Import csv again to update issue links for existing issues (map issue key as well to avoid creation of issue duplicates).

Workaround 2: Scripted post-function

(as recommended by STAGIL using Script Runner or Power Scripts)

  1. Import issues with epic links and relation links as default links (i.e. relates to).

  2. Allow users to change link types in bulk change via workflow-transition with a scripted post-function. Show this option only to issues that have issue links of defined link type.
    (info) The following scripts allows to define link type per issue type. I.e. you can configure a different target parent link for issues of type “Story” then for issues of type “Epic”.

Workflow Post-function Groovy Script

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
 
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext()
 
def currentUser = jiraAuthenticationContext.getLoggedInUser()
 
def issueLinkID
def SAJfieldID
 
if (issue.getIssueType().name == "Epic") {
    issueLinkID = 12345 as Long
    SAJfieldID = 11000 as Long
} else if (issue.getIssueType().name == "Story" || issue.getIssueType().name == "Bug" || issue.getIssueType().name == "Task") {
    issueLinkID = 13579 as Long
    SAJfieldID = 11200 as Long
} else {
    return
}
 
def existingLinks = issueLinkManager.getIssueLinks(issueLinkID).findAll() { it.sourceId == issue.id } //sourceId, wenn Outward-Link; destinationId, wenn Inward-Link (Vorgang dient als Ausgangspunkt)
def SAJfield =  customFieldManager.getCustomFieldObject(SAJfieldID)
 
for (existingLink in existingLinks) {
    def destinationIssueId = existingLink.destinationId as Long //destinationId, wenn Outward-Link; sourceId, wenn Inward-Link (Vorgang dient als Ziel des Links)
    def destinationIssueKey = issueManager.getIssueObject(destinationIssueId).key as String
    log.warn("current: " + issue)
    log.warn("destination: " + destinationIssueKey)
    def SAJfieldValue = issue.getCustomFieldValue(SAJfield) as String
    if (SAJfieldValue == null) {
        issue.setCustomFieldValue(SAJfield, destinationIssueKey)
    } else if (!SAJfieldValue.contains(destinationIssueKey)) {
        issue.setCustomFieldValue(SAJfield, SAJfieldValue + ", " + destinationIssueKey)
    }
    issueLinkManager.removeIssueLink(existingLink, currentUser)
}
 
issueManager.updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false)

(warning) Issue link type ID (12345) to be replaced with actual ID.

(warning) SAJ field ID (11000) to be replaced with actual ID.

(warning) Above script refers to outward links only. If you want to replace inward links instead, sourceId (line 11) and destinationId (line 16) need to be swapped.

Workflow Condition Groovy Script

import com.atlassian.jira.component.ComponentAccessor

def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def existingLinks = issueLinkManager.getIssueLinks(12345).findAll() { it.sourceId == issue.id } as boolean //sourceId, wenn Outward-Link; destinationId, wenn Inward-Link (beides nimmt aktuellen Vorgang als Ausgangspunkt)
    
return existingLinks

(warning) Issue link type ID (12345) to be replaced with actual ID.

(warning) Above script refers to outward links only. If you want to look for inward links instead, sourceId (line 5) to be replaced with destinationId.

  • No labels