How to change Agile Board Name pragmatically

Łukasz Sielski priv May 29, 2020

Hello,

 

I want to copy Kanban Board with scriptrunner, here is the code I have and it works:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectManager
import com.atlassian.greenhopper.service.rapid.view.RapidViewConfigService
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.rapid.view.ColumnService
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.atlassian.greenhopper.service.rapid.view.BoardAdminService
import com.atlassian.greenhopper.manager.rapidview.RapidViewManager
import com.atlassian.greenhopper.web.rapid.view.RapidViewEditHelper
def rapidViewService = ScriptRunnerImpl.getPluginComponent(RapidViewService)
def columnService = ScriptRunnerImpl.getPluginComponent(ColumnService)
@JiraAgileBean
RapidViewConfigService rapidViewConfigService
@JiraAgileBean
BoardAdminService boardAdminService
@JiraAgileBean
RapidViewManager rapidViewManager
@JiraAgileBean
RapidViewEditHelper rapidViewEditHelper
ProjectManager projectManager = ComponentAccessor.getProjectManager()
//variable for Porject role that will be used to grant permissions for filters and Dashboard.
final String projectRole = "10031"
def requestedValue = "jIR"
requestedValue = requestedValue.toUpperCase()
def project = projectManager.getProjectObjByKey(requestedValue)
def LeadName = project.getLeadUserName()
def user = ComponentAccessor.getUserManager().getUserByName(LeadName)

//-----relevant part
def templateBoard = rapidViewService.getRapidView(user, 17884)

def board = rapidViewService.copy(user, templateBoard.getValue())

rapidViewEditHelper.addColumn(user, board.getValue(), "AAAAAAAAAAAAAAAAAAAAAAAA")

 

But now I need to change board name and Filter,  there are methods for this are here... I think:

But I don't have enough JAVA experience to make use of them.

How to create instance of com.atlassian.greenhopper.web.rapid.view.RapidViewEditResource.RapidViewUpdateRequest editModel so I can use it in updateRapidViewName  method?

 

Best Regards,

Lukasz

1 answer

1 accepted

0 votes
Answer accepted
Jamie Echlin _ScriptRunner - The Adaptavist Group_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 9, 2020

Hi.

Changing the board name and contents of the filter are separate, unconnected operations. Each board is associated with one saved filter, so you can change the contents of that saved filter.

Here is an example of changing both name and filter contents:

https://gist.github.com/jechlin-adaptavist/cbc9ec28b9d47ebf8e13184ce7ee610e

(tested on 7.7.0 and 8.0.0). BTW, I skipped error checking to make it clearer.

Separately, you were asking me, basically, how to "know" this stuff.

Not really a simple answer, just practice and a collection of different strategies.

The obvious thing is be familiar with the javadoc, eg https://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/bc/filter/SearchRequestService.html.

That might not get you too far. The next thing is to download the source and understand how to debug it, so you can step through Atlassian's code and see how things hang together. We've tried to explain how to do that at https://scriptrunner.adaptavist.com/latest/jira/DevEnvironment.html, but I won't pretend it's super straightforward.

If I need to know, or re-learn how to do something, eg your example, I will search the source code of ScriptRunner. Typically we are doing something related, somewhere. If not I'll expand the search to the Jira Software source.

Then I'll hack a script together, and do a bit of trial and error, debugging, change some stuff and see what breaks. That's enough normally, if I wanted to take it further or write production code I'd write some integration tests that run inside of Jira.

That's about it really!

cheers, jamie

Suggest an answer

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

Atlassian Community Events