Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can Scriptrunner be used to show the name of a dependent issue instead of its key?

I am using Scriptrunner to display a list of dependencies between issues within a Dashboard for use by the members of the program team and their sponsors. While this is useful to some degree, it would be more helpful to show the name of the dependent issue instead of the Key. I.E. in the dashboard below, we want to show the name of the dependent issue rather than the Key so that we can see what it is without having to click into each one.

Dependencies.png

I haven't been able to work out how to do this however. Is it possible?

3 answers

1 accepted

1 vote
Answer accepted

Here is a complete code that will work for you:

enableCache = {-> false}
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager

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.contains("Epic") && it.issueLinkType.name != ("Cloners") && !it.issueLinkType.name.contains("subtask")}
def subInwardElements = inwardIssueLinks.findAll { !it.issueLinkType.name.contains("Epic") && it.issueLinkType.name != ("Cloners") && !it.issueLinkType.name.contains("subtask")}
def resultYes = "<p>";

if (subOutwardElements.size() > 0) {
for (def i = 0; i < subOutwardElements.size(); i++ ) {
def dependIssue = issueManager.getIssueObject(subOutwardElements[i].destinationId).toString() + " " + issueManager.getIssueObject(subOutwardElements[i].destinationId).getSummary()
resultYes = resultYes + "<div>" + dependIssue + "</div>"
}
resultYes = resultYes + "</p>"
return resultYes
}

if (subInwardElements.size() > 0) {
for (def i = 0; i < subInwardElements.size(); i++ ) {
def dependIssue = issueManager.getIssueObject(subInwardElements[i].sourceId).toString() + " " + issueManager.getIssueObject(subInwardElements[i].sourceId).getSummary()
if (!resultYes.contains(dependIssue.toString())) {
resultYes = resultYes + "<div>" + dependIssue + "</div>"
}
}
return resultYes
}

if (subOutwardElements.size() == 0 || subInwardElements.size() == 0) {
return "No"
}

 Note that i exclude links of type "epic", "sub-task" and "cloners"

If you want to see all link types just remove the exclude from the code.

I tested it before sending to you and it works.

That is absolutely brilliant Nir. Thanks a million!

Like Nir Haimov likes this
0 votes
Nir Haimov Community Leader Nov 19, 2018

Hi,

If you ask if it can be done, than yes.

 

You can create custom scripted field to show you what you want, than just add this field to your filter in Dashboard.

If you expect to get a complete code for this than i'm sorry, you will have to write it on your own.

If you have something you already started to write and you need more guidance, let me know and i will gladly help you

 

Cheers,

Nir.

The filter that is shown above is:

issueFunction in linkedIssuesOf("project = VCS and status != done") ORDER BY "Epic Link

I have a custom scripted field called "Depended By". The following code I have written to get the Summary name of the  first issue instead of the summary name of the linked issue. I've no idea how to get it unfortunately. 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def linkedIssues = issueLinkManager.getOutwardLinks(issue.id)
def summary

issueLinkManager.getInwardLinks(issue.id).each {issueLink ->

for(Iterator outIterator = linkedIssues.iterator(); outIterator.hasNext();){
IssueLink issueLink2 = (IssueLink) outIterator.next()
linkedIssues = issueLink2.getSourceObject().getSummary()
summary = linkedIssues

}

}
return summary

 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

236 views 2 1
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you