I am attempting to script a custom field (via ScriptRunner) to return all linked, dependent issues. It seems to work when I test it in the ScriptRunner console, but doesn't render correctly on the issue screen or search results.
Here is the script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import groovy.xml.MarkupBuilder
import com.atlassian.jira.config.properties.APKeys
def baseUrl = ComponentAccessor.getApplicationProperties().getString("jira.baseurl");
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def issueManager = ComponentAccessor.getIssueManager()
def outwardIssueLinks = issueLinkManager.getOutwardLinks(issue.getId())
def inwardIssueLinks = issueLinkManager.getInwardLinks(issue.getId())
def subOutwardElements = outwardIssueLinks.findAll { it.issueLinkType.name == ("Dependent") }
def subInwardElements = inwardIssueLinks.findAll { it.issueLinkType.name == ("Blocks")}
def issuelist = []
assert issuelist.empty
if (subOutwardElements.size() > 0) {
for (def i = 0; i < subOutwardElements.size(); i++ ) {
def dependIssue = issueManager.getIssueObject(subOutwardElements[i].destinationId)
issuelist.add(dependIssue)
}
}
if (subInwardElements.size() > 0) {
for (def i = 0; i < subInwardElements.size(); i++ ) {
def dependIssue = issueManager.getIssueObject(subInwardElements[i].sourceId)
issuelist.add(dependIssue)
}
}
return issuelist
When I select "preview" to test it on an issue is shows this:
However, on the issue screens it shows:
$issuePickerViewRenderer.getIssuePickerHtml($value)
Thanks for confirming the script works. I've got it working now by changing the default Searcher for the field to "Issue Key Searcher". It defaulted to Free Text. All working now!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Pete Singleton ,
I just tried your script and it is working fine. Are you sure that the field is on a the view issue screen, and that the issues are linked by a "Dependent" or "Blocks" link ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.