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 27, 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!!

1 answer

0 votes
Logan Hawkes July 11, 2022

What's the significance of assigning boardAdmin1 twice?

def boardAdmin1 = boardAdmin1 = boardAdmins + [boardAdmin]

Suggest an answer

Log in or Sign up to answer