How to get all customer request types from project key?

Derek Southard 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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events