Hi!
I am on the hunt for a way to add some dashboards to my users based on which group they are connected to. The reason for this is:
- My users are not that well trained in Jira yet. Therefore it is hard to ask them to search for specific dashboards
- We have different dashboards for different type of users. HR, IT, Security etc. should look at different dashboards
And that is why I need to find a way to add these dashboards to the users and since we have a lot of users I would prefer not to do this manually one by one...
I would also like to only ADD the dashboards, if they already have other favourite dashboards they should not be deleted as favourites. I found this script in the following link JRASERVER-15841:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.portal.PortalPage
import com.atlassian.jira.portal.PortalPageManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.favourites.FavouritesManager
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("")
log.setLevel(Level.DEBUG)
def portalPageIds = [10407,10404]
def groupNames = ['teq_jirasd_administrators']
def groupManager = ComponentAccessor.getGroupManager()
ComponentManager componentManager = ComponentManager.getInstance()
PortalPageManager portalPageManager = (PortalPageManager) componentManager.getComponentInstanceOfType(PortalPageManager.class)
FavouritesManager favouritesManager = (FavouritesManager) componentManager.getComponentInstanceOfType(FavouritesManager.class)
for (String groupName: groupNames) {
def grpUserList = groupManager.getUsersInGroup(groupName)
for (ApplicationUser user:grpUserList){
for (Long portalPageId: portalPageIds) {
PortalPage portalPage = portalPageManager.getPortalPageById(portalPageId)
try{
favouritesManager.addFavourite(user, portalPage)
log.info("Adding portal " + portalPageId.toString() + " to user: " + user)
} catch (Exception ex){
log.warn("Failed Adding portal " + portalPageId.toString() + " to user: " + user + "\n" + ex)
} //catch
} //for portalID
} //for group users
} //for groups
However I get the same error as the user in the comment:
The script could not be compiled:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script162.groovy: 25: expecting '{', found 'Unknown' @ line 25, column 1. Unknown macro:
{ favouritesManager.addFavourite(user, portalPage) log.info("Adding portal " + portalPageId.toString() + " to user}
Perhaps anyone has already done something similar and are able to help me out on this? I would be very grateful!