Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is it possible to modify the dashboard owners massively?

Benjamín Alexander Mella Marilao February 21, 2023

 I have some dashboards that I need to change owners, although Jira has this option within the Built in script, this only allows me to do one by one and it would take a lot of time.(2000 - 5000 dashboard)


I was thinking of using the portalpage in jira, the getDashboardManager() method does not identify me


I leave an example of what I try to do with the jira console:


Consola jira.pngConsola jira - 2.png


Thanks in advance

1 answer

1 accepted

0 votes
Answer accepted
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 21, 2023

Hi @Benjamín Alexander Mella Marilao 

Dashboard class do not exist. JIRA Dashboard are referenced as Portal page.

You have to use the following class

com.atlassian.jira.bc.portal.PortalPageService

com.atlassian.jira.portal.PortalPage

https://docs.atlassian.com/software/jira/docs/api/7.0.4/com/atlassian/jira/bc/portal/PortalPageService.html

 

Regards

Benjamín Alexander Mella Marilao February 22, 2023

Hi @Florian Bonniec 

In case of using Jira 8.20, what class do you recommend I use?

 

Regards!

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 22, 2023

I've not tested it but it should not have changed since 7.0.4

This one should work for 8.20.X

https://docs.atlassian.com/software/jira/docs/api/8.20.3/com/atlassian/jira/bc/portal/PortalPageService.html

 

Regards

I can't get it to workSin título.png

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 2, 2023

Yes the class path is 

com.atlassian.jira.bc.portal.PortalPageService
Regards

but it tells me that it is deprecatedSin título.png

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 2, 2023

Deprecated means that it will be removed at some point but it's working now. You can also use the recommanded function if it's availabl for your version.

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 3, 2023

Hi @Benjamín Alexander Mella Marilao 

 

This code should do the tricks:

Note that the currentUser have to be able to see the dashboard if it's not the case you have to get all dashbaord, then if dashboard id is in your list you update it, do nothing if it's not the case.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.portal.PortalPageService
import com.atlassian.jira.portal.PortalPage
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.portal.PortalPage.Builder

PortalPageService portalPageService = ComponentAccessor.getComponent(PortalPageService.class)
UserSearchService userSearchService = ComponentAccessor.getComponent(UserSearchService)

ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

ApplicationUser targetOwner = ComponentAccessor.getUserManager().getUserByName("YYYYYYYY")

List<Long> portalIds = []

portalIds.each{ id->
    PortalPage dashboard = portalPageService.getPortalPage(new JiraServiceContextImpl(currentUser) , id)
    PortalPage.Builder builder = new Builder()
    builder.portalPage(dashboard)
    builder.owner(targetOwner)
    PortalPage updatedDashbaord = builder.build()
    portalPageService.updatePortalPageUnconditionally(new JiraServiceContextImpl(currentUser), currentUser, updatedDashbaord)
}

 

Suggest an answer

Log in or Sign up to answer