how to get value of linked issue to the issue by using scriptfield.
I have one issue that is linked to another issue.I need one value to show from linked issue to current issue.So i create one script field and try to get linked issue field value.But i'm unable to get that value.Kindly help me to explore JIRA.
This is my code
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
def componentManager = ComponentManager.getInstance()
def issueLinkManager = componentManager.getIssueLinkManager()
def totalRemaining = 0
issueLinkManager.getOutwardLinks(issue.id).each {issueLink ->
if (issueLink.issueLinkType.name == "Version") {
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager();
CustomField cf1 = customFieldManager.getCustomFieldObjectByName("Technical Specialist");
def linkedIssue = issueLink.destinationObject.getCustomFieldValue(cf1);
}
}
return linkedIssue;
Give me simple code.
Thanks in advance.
Community moderators have prevented the ability to post new answers.
Your code is pretty close - the only problems I can see with it are more a question of checking what you're doing. Either in the code or, when you use the "preview" option in the scripted field configuration, making sure that the issue you test with has all the right data.
Give me some sample code.One is issue(A) relates to another issue called (B).B having technical specialist value.I need that value in B issue in the view form.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I may have multiple issue link to single issue.Kindly give me some piece of code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your code is mostly fine, it just needs checking against the data, and the return statement needs a look to help you debug. As for the multiple links, there's two things you could do and you need to decide which it is: 1. You only want one result - decide on the rule that defines which one you want, and put that inside the loop, so that linkedIssue is set to the result and the loop ends 2. You want multiple results - convert linkedIssue into a list of results and instead of a single object def linkedIssue = [] (to get an empty list) ... linkedIssue.add (issueLink.destinationObject.getCustomFieldValue(cf1));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.