Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagegroovy
titleMake dashboards accessible to admin
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.portal.PortalPage
import com.atlassian.jira.portal.PortalPageManager
import com.atlassian.jira.sharing.SharePermission
import com.atlassian.jira.sharing.SharePermissionImpl
import com.atlassian.jira.sharing.SharedEntity.SharePermissions
import com.atlassian.jira.sharing.type.ShareType.Name
import com.atlassian.jira.util.collect.EnclosedIterable.Functions;


def makeDashboardAccessibleToAdmin(long dashboardId) {
	PortalPageManager ppm = ComponentAccessor.getComponent(PortalPageManager.class);
    
	PortalPage portalPage = ppm.getPortalPageById(dashboardId); 
	Set<SharePermission> permissionsSet = new HashSet<SharePermission>(
		portalPage.getPermissions().getPermissionSet()
	);
	permissionsSet.add(new SharePermissionImpl(null, Name.GROUP, "jira-administrators", null));
	ppm.update(PortalPage.portalPage(portalPage).permissions(new SharePermissions(permissionsSet)).build());
}

makeDashboardAccessibleToAdmin(DASHBOARDIDHERE);


Resolution 2:

It is possible that you don’t have permissions to access it (share permissions). You can use a this groovy script to make all dashboards global.

NB! makeAllDashboardsGlobal returns the ids of all changed dashboards. This list can be used to revert the changes, so save it!

...