Hi All,
Is there any way I can pull linked issue values to parent issue.
For example, A is a parent issue and B is linked to A. Is there any way we can retrieve Issue B custom field values in Issue A.
TIA!!
Below is the code I'm using
import com.atlassian.crowd.embedded.api.Userimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.CustomFieldManagerimport com.atlassian.jira.issue.Issue
def Issue issue = issue
def User user = ComponentAccessor.getUserManager().getUserByName("username").getDirectoryUser()def issueLinkManager = ComponentAccessor.issueLinkManager
def linkCollection = issueLinkManager.getLinkCollection(issue, user)
if (linkCollection && linkCollection.allIssues) {def CustomFieldManager customFieldManager = ComponentAccessor.customFieldManagerdef customField = customFieldManager.getCustomFieldObject("customfield_xxxx")def linkedIssue = linkCollection.allIssues.first()return linkedIssue.getCustomFieldValue(customField)}
I get the error at the underlined code.
Hi Ashish,
Were you able to figure it out or do you still need help with this issue?
Josh
Hi Joshua,
Can you please help me on this.
Thanks,Ash.
Hi Ash,
You could create a scripted field that gets values from issues that are linked. For example, if Parent issue A was of type "Bug", the code for your scripted field would look like this:
import com.atlassian.jira.component.ComponentAccessordef issueLinkManager = ComponentAccessor.getIssueLinkManager()def customFieldManager = ComponentAccessor.getCustomFieldManager()if (issue.issueType.name == "Bug") { issueLinkManager.getOutwardLinks(issue.id).first() { issueLink -> // go through all issues linked off of the Story def linkedIssue = issueLink.getDestinationObject()def customField = customFieldManager.getCustomFieldObjectByName("customfield_xxxx")return linkedIssue.getCustomFieldValue(customField) }}
It looks like you're new here. Sign in or register to get started.