While asking this same question in a slightly different context I came up with a nifty solution that should be useful to many. Now that Nic works at Adaptavist I hope you can confirm this is the best way to do it.
Problem:
I used ScriptRunner to generate a list of all issues that have a 'depends on' relationship. The only columns that I could add to show those 'depends on' issue keys was the "Links." However, that shows all linked issues regardless if the type was 'depends on,' 'blocks,' 'blocked by,' 'relates to,' etc. There is no simple way to show "Depends on" as a column.
JQL:
"Clarity Project Name" in ("xxxx") AND issueFunction in hasLinks("depends on")
Note: "Clarity Project Name" is a Custom Field in our Jira.
Solution:
Use ScriptRunner to create a "Scripted Field" called "Depends On", see:
https://scriptrunner.adaptavist.com/5.0.4/jira/scripted-fields.html
Note: Docs are a bit confusing, but essential
import com.atlassian.jira.component.ComponentAccessor;
/* import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
*/
import com.atlassian.jira.component.ComponentAccessor
def browseurl = com.atlassian.jira.component.ComponentAccessor.getApplicationProperties().getString("jira.baseurl")+"/browse/"
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def inlinks = issueLinkManager.getInwardLinks(issue.getId())
//log.debug(inlinks.size())
def keymap = [:]
issueLinkManager.getInwardLinks(issue.getId()).each { issueLink ->
if(issueLink.getIssueLinkType().getInward() == "depends on"){
def ikey = issueLink.getSourceObject().getKey();
//log.debug("iter: "+ikey)
keymap[ikey]="<a href=\""+browseurl+ikey+"\" >"+ikey+"</a>";
}
}
def sortedmap = keymap.sort{a, b ->
def (akey,aval) = a.key.split("-")
def (bkey,bval) = b.key.split("-")
if (akey == bkey)
return aval as int <=> bval as int;
return akey <=> bkey;
}
def keylist = []
sortedmap.each{k,v -> keylist.add(v)}
return keylist.join(", ")
Now "Depends On" field is available in the filter view so that you can show only the "Depends On" links. Not sure why, why Depends On links only show as inward links, and alot of places on the net shows that they should appear on Outward links!?
Hi Vishnu,
did you try die Column Button in the right upper corner?
2016-04-12 11_30_38.png
There you can search for additional fields and add them to the view.
You can even define new fields - please refer to this official documentation.
Hope this helps,
Cheers, Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mario,
Thanks for the reply.
I want to know, Is there a way to add this programatically using the JIRA Java APIs?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you could, but DO NOT DO IT. At best it's a waste of your coding time for almost zero benefit, at worst, it'll just annoy your users.
The columns you see are flexible and chosen by the user. There are three places JIRA looks when choosing columns
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I didn't get that. But unfortunately I cannot give an answer on that. Maybe by doing a javascript post with a customfield_id.
Edit: Thanks Nic!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I read it as "I want to write code that will add columns to the settings", which is one of those actions that upsets users (the nice ones will simply delete it again, the grumpy ones like me will have a go at the admins for interfering with their stuff).
I like your answer because the columns should be left up to the users.
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.