Forums

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

How can I add a Group in an existing Board Admin list of any board?

Himanshi Maheshwari July 26, 2018

When I am trying the below code. In which I am first fetching the list of Board Admins and adding a group say "Test_Group" in that list and updating the same Board admins with the new list. It is throwing an error "Not Implemented". But when I am fetching board admins from 1 board and adding a group and updating some other board with the new list it is updating successfully. But my task is to fetch from first board and update the first board only with the new admin list.

 

import com.atlassian.greenhopper.service.rapid.view.BoardAdminService
import com.onresolve.scriptrunner.runner.customisers.PluginModuleCompilationCustomiser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.greenhopper.service.rapid.ProjectRapidViewService
import com.onresolve.scriptrunner.runner.customisers.PluginModuleCompilationCustomiser
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.greenhopper.model.rapid.BoardAdmin
import com.atlassian.greenhopper.model.rapid.RapidView
import com.atlassian.greenhopper.manager.rapidview.RapidViewManager
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.manager.rapidview.BoardAdminManagerImpl
//import com.atlassian.greenhopper.manager.rapidview.RapidViewManagerImpl

def rapidViewService = PluginModuleCompilationCustomiser.getGreenHopperBean(RapidViewService)
//def rapidViewManager = PluginModuleCompilationCustomiser.getGreenHopperBean(RapidViewManagerImpl)
def groupManager = ComponentAccessor.getGroupManager()
def BoardAdminManager = PluginModuleCompilationCustomiser.getGreenHopperBean(BoardAdminManagerImpl)

def projectRapidViewService = PluginModuleCompilationCustomiser.getGreenHopperBean(ProjectRapidViewService)

 

/*Fetching Boards using Project Key*/

def boards = projectRapidViewService.findRapidViewsByProject(
ComponentAccessor.jiraAuthenticationContext.loggedInUser,
ComponentAccessor.projectManager.getProjectByCurrentKey("XYZ")
).value
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser


def boardAdminService = PluginModuleCompilationCustomiser.getGreenHopperBean(BoardAdminService)

def rapidView = boards[0]
def rapidView1 = boards[1]

 /*Fetching Board Admins of any particular board*/

def boardAdmins = boardAdminService.getBoardAdmins(rapidView)
def newAdmin = groupManager.getGroupObject("Test_Group")
def boardAdmin = BoardAdmin.builder().type(BoardAdmin.Type.GROUP).key(newAdmin.name).build()

/*Adding the existing list with a new group*/
def boardAdmin1 = boardAdmin1 = boardAdmins + [boardAdmin]

/*Updating the list*/

BoardAdminManager.updateBoardAdmin(rapidView,boardAdmin1)

 

Please help me asap. Thanks in advance!!

3 answers

0 votes
Stephen Garber
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.
March 19, 2025

Did you find a way to do this?

 

I've been searching a ton and haven't been able to get a script that updates the board admins working.

0 votes
Anders Lantz March 5, 2020

I have a similar issue when trying to do this:

import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.greenhopper.manager.rapidview.RapidViewManager
import com.atlassian.greenhopper.model.rapid.BoardAdmin
import com.atlassian.greenhopper.model.rapid.RapidView

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

@JiraAgileBean
RapidViewManager rapidViewManager

@JiraAgileBean
BoardAdminService boardAdminService

ArrayList<RapidView>allBoards = rapidViewManager.getAll().value
ArrayList<BoardAdmin> originalPermissions = boardAdminService.getBoardAdmins(allBoards.first())

try {
boardAdminService.updateBoardAdmins(allBoards.first(),userManager.getUserByName("localadmin"),originalPermissions)
}catch(all) {
log.debug(all.message)
}

 

This prints the error: Not implemented

 

I obviously want to do more and update with the old permissions but when I try to create new permissions I get the same problem.

Dmitriy.Khalturin March 5, 2020

"originalPermissions" has id and other attributes
I think updateBoardAdmins processes these attributes and we have "Not implemented".
If you pass a list to the function without them, then everything will work. As I wrote above, I reload a list and it works for me.

Anders Lantz March 5, 2020

Well that med a hell of a difference, many thanks @Dmitriy.Khalturin !!

I was just so focused on that I probably needed to generate new ID´s for my new permissions, I didn't think about not being able to reuse the older ID´s.

 

So in short, if you are keeping any of the older permissions recreate them:

 

newPermissions.add(BoardAdmin.builder().type(originalPermission.type).key(originalPermission.key).build())
0 votes
Dmitriy.Khalturin February 18, 2020

Hi !

I use this code:

/*Fetching Board Admins of any particular board*/
def boardAdmins = boardAdminService.getBoardAdmins(rapidView)

/* Reload admins in new list*/
List<BoardAdmin> boardAdmin1 = new ArrayList<BoardAdmin>()
boardAdmins.each(){ admin ->
boardAdmin1.add(BoardAdmin.builder().type(admin.getType()).key(admin.getKey()).build())
}

def newAdmin = groupManager.getGroupObject("Test_Group")
def boardAdmin = BoardAdmin.builder().type(BoardAdmin.Type.GROUP).key(newAdmin.key).build()

/*Adding the existing list with a new group*/
boardAdmin1.add(boardAdmin)

/*Updating the list*/

boardAdminService.updateBoardAdmin(rapidView,user,boardAdmin1)
Anders Lantz March 5, 2020

I belive this wont work as Groups dont have a key property:

newAdmin.key
Like Dmitriy.Khalturin likes this
Dmitriy.Khalturin March 5, 2020

Yes, it's a error-typo.
Must be

def boardAdmin = BoardAdmin.builder().type(BoardAdmin.Type.GROUP).key("Test_Group").build()

Suggest an answer

Log in or Sign up to answer