The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all customer request types from project key?

Deleted user
August 8, 2019

I want to write a groovy script to create a map of all request types with their keys for a given service desk. I've gotten it to work using the RequestTypeService class, but I can only get it to work using the Portal ID, not the Project Key. I'm probably missing something obvious. Any help would be greatly appreciated. Here's what I've tried so far:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.requesttype.RequestTypeService

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

def requestTypeService = ComponentAccessor.getOSGiComponentInstanceOfType(RequestTypeService)
def reqQ = requestTypeService.newQueryBuilder().serviceDesk(2).build()
def reqT = requestTypeService.getRequestTypes(currentUser, reqQ)

def requestTypes = [:]
def requestType = reqT.right.results.toArray()
for (i = 0; i < requestType.length; i++) {
requestTypes.put(requestType[i].getName(),requestType[i].key)
}
return requestTypes

 

0 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

TAGS
AUG Leaders

Atlassian Community Events