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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Error in groovy, unable to create dashboard using portletConfigurationManager.addDashBoardItem

We are trying to create an dashboard using groovy script and getting error. Find below details. Jira version 8.2.0

import com.atlassian.fugue.Option
import com.atlassian.gadgets.dashboard.Color
import com.atlassian.gadgets.dashboard.Layout
import com.atlassian.jira.bc.JiraServiceContext
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.bc.portal.PortalPageService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchRequest
import com.atlassian.jira.issue.search.SearchRequestManager
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.portal.PortalPage
import com.atlassian.jira.portal.PortletConfigurationManager
import com.atlassian.jira.sharing.SharedEntity

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
JiraServiceContext sourceUserServiceCtx = new JiraServiceContextImpl(user)

def portalPageService = ComponentAccessor.getComponent(PortalPageService)
def portletConfigurationManager = ComponentAccessor.getComponent(PortletConfigurationManager)
def searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager)
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)

def dashboardTemplate = new PortalPage.Builder()
.name("My new dash")
.description("Info....")
.owner(user)
.layout(Layout.AA)
.permissions(SharedEntity.SharePermissions.GLOBAL)
.build()

def query = jqlQueryParser.parseQuery("project = JRA")

// share filter globally
def templateSearchRequest = new SearchRequest(query, user, "JRA issues", "my description")
templateSearchRequest.setPermissions(SharedEntity.SharePermissions.GLOBAL)
def newSearchRequest =searchRequestManager.create(templateSearchRequest)

// note that portal page names must be unique per user
if (! portalPageService.validateForCreate(sourceUserServiceCtx, dashboardTemplate)) {
return sourceUserServiceCtx.errorCollection
}

def targetDash = portalPageService.createPortalPage(sourceUserServiceCtx, dashboardTemplate)

portletConfigurationManager.addDashBoardItem(targetDash.id, 0, 0,
Option.some(URI.create('rest/gadgets/1.0/g/com.atlassian.jira.gadgets:assigned-to-me-gadget/gadgets/assigned-to-me-gadget.xml')),
Color.color1,
[
'isConfigured': 'true',
'refresh' : '15',
'sortColumn' : '',
'columnNames' : 'issuetype|issuekey|summary|priority',
'num' : '10'
],
Option.none()
)

portletConfigurationManager.addDashBoardItem(targetDash.id, 1, 0,
Option.some(URI.create('rest/gadgets/1.0/g/com.atlassian.jira.gadgets:filter-results-gadget/gadgets/filter-results-gadget.xml')),
Color.color2,
[
"filterId" : newSearchRequest.id.toString(),
'isConfigured': 'true',
'refresh' : 'false',
"isPopup" : "false",
'columnNames' : 'issuetype|issuekey|summary|priority',
'num' : '10'
],
Option.none()
)

 

Error: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.portal.PortletConfigurationManagerImpl.addDashBoardItem() is applicable for argument types: (java.lang.Long, java.lang.Integer, java.lang.Integer, com.atlassian.fugue.Option$Some, com.atlassian.gadgets.dashboard.Color, java.util.LinkedHashMap, com.atlassian.fugue.Option$2) values: [10601, 0, 0, some(rest/gadgets/1.0/g/com.atlassian.jira.gadgets:assigned-to-me-gadget/gadgets/assigned-to-me-gadget.xml), ...] Possible solutions: addDashBoardItem(java.lang.Long, java.lang.Integer, java.lang.Integer, io.atlassian.fugue.Option, com.atlassian.gadgets.dashboard.Color, java.util.Map, io.atlassian.fugue.Option) at Script32.run(Script32.groovy:55)

1 answer

Hi, 

I think your code is from ScriptRunner example to create Dashboards and Gadgets

https://scriptrunner.adaptavist.com/latest/jira/recipes/dashboard-gadgets.html

There is an error, at least for JIRA versions over 8.2, I haven't tried in others.

Change import com.atlassian.fugue.Option for import io.atlassian.fugue.Option that should be enough if you are using mentioned example. 

I just faced that issue using that code, and applying that change it worked.

Regards

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

290 views 2 5
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you