Jira script get custom field value from linked issue Edited

Hey guyz,

I stuck here, can you help me pls.

 

I have 2 issue. For example issue A and B. In issue A, i have a custom field and it's name Sprint. I created scripted custom field "Sprintvalue" in issue B. I want to get value of Sprint and show it in Sprintvalue.

B created by A btw. İssue type=created by

I am using text field template

 

i have code like this but does not work:/ 

 

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager

def componentManager = ComponentManager.getInstance()
def issueLinkManager = componentManager.getIssueLinkManager()
def cfManager = ComponentManager.getInstance().getCustomFieldManager()

def SP = ""
issueLinkManager.getOutwardLinks(issue.id).each {issueLink ->
if (issueLink.issueLinkType.name == "created by") {
def linkedIssue = issueLink.destinationObject
cf = cfManager.getCustomFieldObjects(issue).find {it.name == 'Sprint'}
SP = linkedIssue.getCustomFieldValue(cf)

}
}
return SP

 

1 answer

i found solution.

 

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager

def componentManager = ComponentManager.getInstance()
def issueLinkManager = componentManager.getIssueLinkManager()
def cfManager = ComponentManager.getInstance().getCustomFieldManager()

def SP =""
links = issueLinkManager.getInwardLinks(issue.id)
links.each {
if (it.issueLinkType.name == "Defect") {
def linkedIssue = it.getSourceObject()
cf = cfManager.getCustomFieldObjects(issue).find {it.name == 'Sprint'}
SP = linkedIssue.getCustomFieldValue(cf)
SP = SP.name.toString().replace("[","").replace("]","")
}
}
return SP   

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,760 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot