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

How can I add custom columns inside JIRA issue List View programatically?

Jira List View Q1.png

I have to add a column in the Jira Issue List view programatically. Or I want to append data to the "Summary" column?.

2 answers

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 

 

Hi Mario,

Thanks for the reply.

I want to know, Is there a way to add this programatically using the JIRA Java APIs? 

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

  1. If the user has viewed a saved filter which has had its layout defined, it will use that layout.   You will upset the owners and users of that filter if you add junk they don't want.
  2. The user's personal preferences on columns.  This is the one you absolutely should not touch - it's chosen by the users. It's a bit like breaking into someone's house and rearranging the furniture without their permission
  3. The system default.  You could touch this one safely, but there's no point - it's far easier to just get the admin to add it

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!

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.

@Nic Brough {Adaptavist}  

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

  • Add a new Custom Field via the normal way in Jira, making it of type Scripted Field.  No need to add to any screen.
  • Then go to Admin -> Manage Apps -> [Left Menu under ScriptRunner] Script Fields -> <YOU NEWLY CREATED FIELD> -> [Cog Wheel under Actions] -> Edit.
  • Enter the Groovy code below into the script area
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!?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

247 views 1 2
Join discussion

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