Forums

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

Get jira project boards with column names and status names in these columns using scriptrunner

Chamdarig Dall May 14, 2025

Hi Team, how can I get jira project boards with column names and status names in these columns using Adaptavist Scriptrunner for Jira Data Center

3 answers

2 accepted

0 votes
Answer accepted
jiraestro May 29, 2025

@Stefan Stadler you inspired me to develop this code:

import com.atlassian.greenhopper.model.rapid.Column
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.rapid.view.ColumnService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.status.Status
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.pyxis.greenhopper.jira")

@JiraAgileBean
RapidViewService rapidViewService

@JiraAgileBean
ColumnService columnService

def applicationUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

// Your real board IDs here:
def targetBoardIds = [1L, 2L]

def htmlBuilder = new StringBuilder()

htmlBuilder << "<table border='1' cellspacing='0' cellpadding='5' style='border-collapse: collapse;'>"
htmlBuilder << "<thead><tr>"
htmlBuilder << "<th>Board Name</th><th>Board ID</th><th>Column Name</th><th>Status Name</th>"
htmlBuilder << "</tr></thead><tbody>"

if (rapidViewService) {
def rapidViews = rapidViewService.getRapidViews(applicationUser).value

rapidViews
.findAll { it.id in targetBoardIds }
.each { rapidView ->

def columnsByStatus = columnService.getColumnsByStatus(rapidView)

def columnStatusMap = [:]
columnsByStatus.each { Status status, Column column ->
columnStatusMap[column.name] = columnStatusMap.get(column.name, []) + status.name
}

columnStatusMap.each { columnName, statusNames ->
statusNames.eachWithIndex { statusName, idx ->
htmlBuilder << "<tr>"
if (idx == 0) {
htmlBuilder << "<td rowspan='${statusNames.size()}'>${rapidView.name}</td>"
htmlBuilder << "<td rowspan='${statusNames.size()}'>${rapidView.id}</td>"
htmlBuilder << "<td rowspan='${statusNames.size()}'>${columnName}</td>"
}
htmlBuilder << "<td>${statusName}</td>"
htmlBuilder << "</tr>"
}
}
}
}

htmlBuilder << "</tbody></table>"

// Return the HTML result
return htmlBuilder.toString()

 

Chamdarig Dall May 29, 2025

Thank you both! This is what I was looking for :)

0 votes
Answer accepted
Stefan Stadler
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.
May 20, 2025

Hi @Chamdarig Dall 

actually, there is some code to access the boards using ScriptRunner.

the following code can iterate over all boards and print out the mapping for each Status and also lists a mapping for the respective columns. This can be modified of course to what exactly is needed by your usecase:

import com.atlassian.greenhopper.model.rapid.Column
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.rapid.view.ColumnService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.status.Status
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.pyxis.greenhopper.jira")

@JiraAgileBean
RapidViewService rapidViewService

@JiraAgileBean
ColumnService columnService

def applicationUserInput = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if(rapidViewService) {
def rapidViews = rapidViewService.getRapidViews(applicationUserInput).value
rapidViews.each{
Map<Status, Column> columns = columnService.getColumnsByStatus(it)
columns.each{Status status, Column column ->
log.warn("Status name: ${status.name}")
log.warn(" Column name: ${column.name}")
log.warn(" Complete list of status IDs: ${column.statusIds.join(", ")}")
log.warn("__________________")
}
}
}
0 votes
Dick
Community Champion
May 14, 2025

Hello @Chamdarig Dall 

Big question for me here is: why use Scriptrunner as building the board you desire can be done in Jira right out of the box?

Kind regards,
Dick

Chamdarig Dall May 14, 2025

I don't need it for building. I need it to get data about boards for reporting

Dick
Community Champion
May 15, 2025

A board is just a pair of glasses to look at the current status of a (part of a) project or projects. There's data in the work items. 

When you're talking about reporting, you implicitly are interested in what has been done in past sprints. For this, Jira has the reporting section, where you can visualize metrics over past sprints. This section is full of handy charts and calculations, those of which you cannot obtain from boards in an easy manner. So why not start using sprints (or when you're more Kanban oriented, start using releases) and use the reporting section?

Kind regards,
Dick

Chamdarig Dall May 15, 2025

Nope, I mean exactly what I wrote, "Get jira project boards with column names and status names in these columns"

I can get it via the REST API:

/rest/agile/1.0/board/{boardId}/configuration

But I was curious if I could get it with Scriptrunner

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events