Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a list of columns in Java API?

Ioan Bularca February 12, 2020

Hi,

I am developing a Jira plugin using Java API, I need to gather a list of columns according to a project. I don't know how to use ColumnLayoutManager and I am not sure if this interface can help me.

 To be more explicit I would like to write a function something like that:

List<Column> getAllColumnsFromProject(ApplicationUser user, Long projectId){

//returns list of columns

}

1 answer

0 votes
Leonard Chew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 12, 2020

Adapt your code to java syntax.

Here is a groovy script to list the custom fields of project 'TEC', issue type 'Story'.

The class you need is
com.atlassian.jira.component.ComponentAccessor

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.ConstantsManager
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def projectManager = ComponentAccessor.getProjectManager()
def projectID = projectManager.getProjectByCurrentKey('TEC').id
def customFieldList = customFieldManager.getCustomFieldObjects(projectID,ConstantsManager.ALL_ISSUE_TYPES)

for (f in customFieldList) {
log.debug(f.name)
}

 

see:

https://docs.atlassian.com/software/jira/docs/api/8.5.0/com/atlassian/jira/issue/CustomFieldManager.html#getCustomFieldObjects--

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events