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