Copy field value from linked issue


Use a post function to copy any field value from a linked issue to the issue in transition.


When an issue is updated, I want to assign a specific field of all linked issues to the same value which the updated issue now has.

Good to Know

fieldNameToCopy: The field name of which the value will get copied. issueLinkNameToSync: The issue linked with that link type will be used as the source issue.


Jira Jira (7.7 - 8.6)

import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.IssueFieldConstants // the name of the field to copy final String fieldNameToCopy = "Priority" // leave blank to copy from the last linked issue (regardless the link type) final String issueLinkTypeName = "Blocks" def fieldManager = ComponentAccessor.fieldManager def fieldToCopy = fieldManager.allAvailableNavigableFields.find { == fieldNameToCopy } if (!fieldToCopy) { "Could not find field with name $fieldNameToCopy" return } def linkedIssues = ComponentAccessor.issueLinkManager.getOutwardLinks( if (!linkedIssues) { "There are no linked issues" return } if (issueLinkTypeName && !(issueLinkTypeName in linkedIssues*.issueLinkType*.name)) { "Could not find any issue, linked with the $issueLinkTypeName issue type" return } def linkedIssue = issueLinkTypeName ? linkedIssues.findAll { == issueLinkTypeName }.last().destinationObject : linkedIssues.last().destinationObject def fieldToCopyId = switch (fieldToCopyId) { case fieldManager.&isCustomFieldId: def customField = ComponentAccessor.customFieldManager.getCustomFieldObject(fieldToCopyId) def linkedIssueCustomFieldValue = linkedIssue.getCustomFieldValue(customField) issue.setCustomFieldValue(customField, linkedIssueCustomFieldValue) break case IssueFieldConstants.COMPONENTS: def commonComponents = linkedIssue.components.findAll { in issue.components*.name } issue.setComponent(commonComponents) break case IssueFieldConstants.FIX_FOR_VERSIONS: def commonFixedVersions = linkedIssue.fixVersions.findAll { in issue.fixVersions*.name } issue.setFixVersions(commonFixedVersions) break case IssueFieldConstants.AFFECTED_VERSIONS: def commonVersions = linkedIssue.affectedVersions.findAll { in issue.affectedVersions*.name } issue.setFixVersions(commonVersions) break default: issue[fieldToCopyId] = linkedIssue[fieldToCopyId] }
Discovered an issue? Report it here

Suggested for you