Script to add dashboard to others favorites

Hi,

I am looking to add a dashboard to a number of users favorites, so when they are given there logins a number of default dashboards are provided. I found the below answer that points me in the right direction, but unfortunatly my instance does not have access to

import com.opensymphony.user.UserManager

as such I have looked for something within the jira utils that would allow me to acheive the same but I am struggling.

https://answers.atlassian.com/questions/4687/request-working-script-to-favorite-issue-on-behalf-of-all-users

Could someone please help...

Thanks in advance

Dan

8 answers

1 accepted

I found an updated version of the code in:

https://jira.atlassian.com/browse/JRA-15841

and removed the result part to give:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.favourites.FavouritesManager
import com.atlassian.jira.portal.PortalPage
import com.atlassian.jira.portal.PortalPageManager
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.crowd.embedded.api.*

// Set the portal page ID and group to share with here
Long portalPageId = xxxxx
String shareWith = "group name"

ComponentManager componentManager = ComponentManager.getInstance()
FavouritesManager favouritesManager = (FavouritesManager) componentManager.getComponentInstanceOfType(FavouritesManager.class)
PortalPageManager portalPageManager = (PortalPageManager) componentManager.getComponentInstanceOfType(PortalPageManager.class)
PortalPage portalPage = portalPageManager.getPortalPageById(portalPageId)
UserUtil userUtil = componentManager.getUserUtil()
CrowdService crowdService = componentManager.getCrowdService()
String Result = ""

for (User user in userUtil.getUsers())
{
if (crowdService.isUserMemberOfGroup(user.getName(), shareWith))
{ favouritesManager.addFavourite(user, portalPage) }

}

Hope this helps someone else...

Hi,

I did this via database scripts and it worked fine for me. 4 different tables are effected:
FavouriteAssociations
GadgetUserPreference
PortalPage
PortletConfiguration

1. Shutdown JIRA
2. Backup database
3. check the dashboard you wish to copy in the 3 tables: PortalPage, PortletConfiguration, GadgetUserPreference and note all of these values
e.g.

select * from portalpage where id like '10000';
select * from portletconfiguration where portalpage like '10000';
select * from gadgetuserpreference where portletconfiguration like '10002';

4. insert the noted values (make copies of the dashboard)

insert into portalpage values ('11721','username','Dashboardname','Dashboarddescr',NULL,'1',NULL,'0');
insert into portletconfiguration values ('19629','11721',NULL,'0','0','rest/gadgets/1.0/g/com.atlassian.jira.gadgets:project-gadget/gadgets/project-gadget.xml',NULL);
insert into gadgetuserpreference values ('12919','19629','projectinfo','full');
...
insert into favouriteassociations values ('13541','username','PortalPage','11721','7');

5. Startup JIRA and enjoy the copied dashboard

0 votes
Renjith Pillai Community Champion Feb 05, 2013

That post is for making the filter favorite, not dashboard.

correct - but this can be altered by replacing all "SearchRequest" texts by "PortalPage" as discussed in :

https://answers.atlassian.com/questions/119848/set-dashboard-for-multiple-users-via-api

Thanks Renjith - I have been looking around this but the issue is this is not a direct replacement for the com.opensymphony.user.UserManager. Therfore I do not understand how I pass a string of a group, returning the users and then add the dashboard to the favourites.

Hi Thomas Heyne, Hi Daflint

I have a similar issue . Are you able to help me out in finding the script to manage Dashboard as favourite to all users .

Could you please tell if you had the similar issue and let me know if there is any GOTCHA's or what bugs may arise by running this script? Can you please tell what version of JIRA you been used.

Any help on this is appreciated.

Kind regards,
Priya

Hi Priya,

The script runner script I used allows you to publish a dashboard to a group of users favorites. If you wanted to set it to all active users - just use "jira-user" as the group. You will need the script runner plugin though.

I have not experienced any issues when running this script and have used this on jira 5.12.

If you have any issues please let me know.

Dan

Hi Daflint,

I have been encountering an error message. Are you able to help me ?

I am trying the below script for multiple groups. See below

------------------------------------------------------------------------------------------------------------------

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.favourites.FavouritesManager
import com.atlassian.jira.portal.PortalPage
import com.atlassian.jira.portal.PortalPageManager
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.crowd.embedded.api.*

// Set the portal page ID and group to share with here

Long portalPageId = 10371

String shareWith = "Aviation - Pluto A"
"Aviation-AerotechniQ","Aviation-Air-North","Aviation-Air-Safety-Navigators","Aviation-Alliance-Airlines" ,"Aviation-Audacia" ,"Aviation-Bristow-Users","Aviation-CHC-Helicopters","Aviation-coordinators","Aviation-Crest Odyssey II",
"Aviation-DB30","Aviation-DDKG2","Aviation-Flight-Safety-Helideck","Aviation-Flight-Safety-Operator","Aviation-Geco-Eagle","Aviation-Geo Atlantic","Aviation-Geo-Natuna","Aviation-Global 1201","Aviation-Goodwyn-A",
"Aviation-HelicopterNZ-Users","Aviation-Hermod","Aviation-Jack-Bates","Aviation-Karratha-Flying-Services","Aviation-LNG Tankers","Aviation-Maersk-Discoverer","Aviation-Maersk-Ngujima-Yin","Aviation-MHS Aviation","Aviation-Network",
"Aviation-Nganhurra","Aviation-North-RankinA","Aviation-NorthernEndeavour-Users","Aviation-pending","Aviation-Polarcus Alima","Aviation-Rockwater-2","Aviation-Safe Astoria","Aviation-Skandi Hercules",
"Aviation-SkippersAviation-Users","Aviation-Skytraders","Aviation-Thylacine-A","Aviation-Transocean-Legend"


ComponentManager componentManager = ComponentManager.getInstance()
FavouritesManager favouritesManager = (FavouritesManager) componentManager.getComponentInstanceOfType(FavouritesManager.class)
PortalPageManager portalPageManager = (PortalPageManager) componentManager.getComponentInstanceOfType(PortalPageManager.class)
PortalPage portalPage = portalPageManager.getPortalPageById(portalPageId)
UserUtil userUtil = componentManager.getUserUtil()
CrowdService crowdService = componentManager.getCrowdService()
String Result = ""

for (User user in userUtil.getUsers())
{
if (crowdService.isUserMemberOfGroup(user.getName(), shareWith))
{ favouritesManager.addFavourite(user, portalPage) }

}

---------------------------------------------------------------------------------------------------------------

The error i am finding when i select script engine Groovy (Groovy Scripting Engine, version: 2.0, registered extensions: [groovy])

Result:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 13: unexpected token: Aviation-AerotechniQ @ line 13, column 1. "Aviation-AerotechniQ","Aviation-Air-North","Aviation-Air-Safety-Navigators","Aviation-Alliance-Airlines" ,"Aviation-Audacia" ,"Aviation-Bristow-Users","Aviation-CHC-Helicopters","Aviation-coordinators","Aviation-Crest Odyssey II", ^ 1 error

Stack Trace:
javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 13: unexpected token: Aviation-AerotechniQ @ line 13, column 1.
   "Aviation-AerotechniQ","Aviation-Air-North","Aviation-Air-Safety-Navigators","Aviation-Alliance-Airlines" ,"Aviation-Audacia" ,"Aviation-Bristow-Users","Aviation-CHC-Helicopters","Aviation-coordinators","Aviation-Crest Odyssey II",
   ^

1 error

	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:122)
	at javax.script.AbstractScriptEngine.eval(Unknown Source)
	at com.onresolve.jira.groovy.GroovyRunner.runFile(GroovyRunner.java:110)
	at com.onresolve.jira.groovy.GroovyRunner.run(GroovyRunner.java:61)
	at com.onresolve.jira.groovy.GroovyRunner.doExecute(GroovyRunner.java:244)
	at webwork.action.ActionSupport.execute(ActionSupport.java:165)
	at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:82)
	at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:39)
	at webwork.interceptor.NestedInterceptorChain.proceed(NestedInterceptorChain.java:31)
	at webwork.interceptor.ChainedInterceptor.intercept(ChainedInterceptor.java:16)
	at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:35)
	at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:221)
	at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:150)
	at com.atlassian.jira.web.dispatcher.JiraWebworkActionDispatcher.service(JiraWebworkActionDispatcher.java:153)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.jira.web.filters.steps.ChainedFilterStepRunner.doFilter(ChainedFilterStepRunner.java:78)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.jira.web.filters.XContentTypeOptionsNoSniffFilter.doFilter(XContentTypeOptionsNoSniffFilter.java:22)
	at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.core.filters.HeaderSanitisingFilter.doFilter(HeaderSanitisingFilter.java:44)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
	at com.atlassian.labs.botkiller.BotKillerFilter.doFilter(BotKillerFilter.java:36)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
	at com.atlassian.jira.tzdetect.IncludeResourcesFilter.doFilter(IncludeResourcesFilter.java:39)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:25)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
	at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
	at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.jira.web.filters.accesslog.AccessLogFilter.executeRequest(AccessLogFilter.java:103)
	at com.atlassian.jira.web.filters.accesslog.AccessLogFilter.doFilter(AccessLogFilter.java:87)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.jira.security.xsrf.XsrfTokenAdditionRequestFilter.doFilter(XsrfTokenAdditionRequestFilter.java:54)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
	at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
	at com.atlassian.jira.web.filters.SitemeshPageFilter.doFilter(SitemeshPageFilter.java:124)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
	at com.atlassian.labs.remoteapps.modules.permissions.ApiScopingFilter.doFilter(ApiScopingFilter.java:60)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
	at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
	at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.seraph.filter.SecurityFilter.doFilter(SecurityFilter.java:234)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:98)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.seraph.filter.BaseLoginFilter.doFilter(BaseLoginFilter.java:169)
	at com.atlassian.jira.web.filters.JiraLoginFilter.doFilter(JiraLoginFilter.java:70)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
	at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:71)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
	at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
	at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.util.profiling.filters.ProfilingFilter.doFilter(ProfilingFilter.java:99)
	at com.atlassian.jira.web.filters.JIRAProfilingFilter.doFilter(JIRAProfilingFilter.java:19)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.johnson.filters.AbstractJohnsonFilter.doFilter(AbstractJohnsonFilter.java:71)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.gzipfilter.GzipFilter.doFilterInternal(GzipFilter.java:80)
	at com.atlassian.gzipfilter.GzipFilter.doFilter(GzipFilter.java:51)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
	at com.atlassian.labs.remoteapps.modules.oauth.OAuth2LOFilter.doFilter(OAuth2LOFilter.java:70)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
	at com.atlassian.labs.remoteapps.util.http.bigpipe.RequestIdSettingFilter.doFilter(RequestIdSettingFilter.java:22)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
	at com.sysbliss.jira.plugins.workflow.servlet.JWDSendRedirectFilter.doFilter(JWDSendRedirectFilter.java:25)
	at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
	at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
	at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
	at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.jira.web.filters.steps.ChainedFilterStepRunner.doFilter(ChainedFilterStepRunner.java:78)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.core.filters.cache.AbstractCachingFilter.doFilter(AbstractCachingFilter.java:33)
	at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.core.filters.encoding.AbstractEncodingFilter.doFilter(AbstractEncodingFilter.java:41)
	at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31)
	at com.atlassian.jira.web.filters.PathMatchingEncodingFilter.doFilter(PathMatchingEncodingFilter.java:49)
	at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.jira.web.monitor.ActiveRequestsFilter$PassToChainFilterFunc.doFilter(ActiveRequestsFilter.java:346)
	at com.atlassian.jira.web.monitor.ActiveRequestsFilter$DebugLogFilterFunc.doFilter(ActiveRequestsFilter.java:463)
	at com.atlassian.jira.web.monitor.ActiveRequestsFilter.doFilter(ActiveRequestsFilter.java:173)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.jira.startup.JiraStartupChecklistFilter.doFilter(JiraStartupChecklistFilter.java:75)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.multitenant.servlet.MultiTenantServletFilter.doFilter(MultiTenantServletFilter.java:91)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.atlassian.jira.web.filters.steps.ChainedFilterStepRunner.doFilter(ChainedFilterStepRunner.java:78)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
	at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 13: unexpected token: Aviation-AerotechniQ @ line 13, column 1.
   "Aviation-AerotechniQ","Aviation-Air-North","Aviation-Air-Safety-Navigators","Aviation-Alliance-Airlines" ,"Aviation-Audacia" ,"Aviation-Bristow-Users","Aviation-CHC-Helicopters","Aviation-coordinators","Aviation-Crest Odyssey II",
   ^

1 error

	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302)
	at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:149)
	at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:119)
	at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:131)
	at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:359)
	at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:141)
	at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:107)
	at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
	at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:160)
	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:843)
	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:548)
	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:524)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:501)
	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:267)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:214)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:342)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:114)
	... 152 more

--------------------------------------------------------------------------------------------------------------

Are you able to tell what might be incorrect here.

Thanks in advance.

Kind regards,
Priya

Hi Priya,

The code above provided is just for use with one dashboard to one group. Im sure it can be modified to take an array of groups and publish to each.

The alternative would be to nest those groups within a group and use the current code to assign it to the new group.

If you have any questions please let me know.

Dan

0 votes

Please refer:

[JRASERVER-15841] Allow the ability to share filters/dashboards rather than the current publish/subscribe model - force favourites - Create and track feature requests for Atlassian products.

/*
 This script can be run from Scriptrunner console to set Dashboards
 listed in the variable portalPageIds as favourites for users from
 groups listed in the variable groupNames
*/
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 = [10100,10200]
def groupNames = ['attach-dashboard-group']
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

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,039 views 13 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot