Jira 8 ServiceDesk 4 Scritrunner - getrequesttype in listener

Jon Starbird
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 7, 2019

I have the following code that worked before upgrading to Jira 8/ServiceDesk4 but now it does not and I have not been able to find a replacement for this. This is in a listener and I am just needing to get the request type.

 

def requestTypeEither = ComponentAccessor.getOSGiComponentInstanceOfType(RequestTypeService).getRequestTypes(curUser,sourceIssueRequestTypeQuery)

if (requestTypeEither.isLeft()) {
log.error "${requestTypeEither.left().get()}"
return
}
def requestType = requestTypeEither.right.results[0]

 

What is the new method?

 

2 answers

1 accepted

1 vote
Answer accepted
Jon Starbird
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 7, 2019

Finally figured it out. 

Have to change:

def requestType = requestTypeEither.right.results[0]

to:

def requestType = requestTypeEither.results[0].getName()

0 votes
Jon Starbird
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 7, 2019

Mean to include, the error i'm getting is:

groovy.lang.MissingPropertyException: No such property: right for class: com.atlassian.servicedesk.api.util.paging.PagedResponseImpl at Script171.run(Script171.groovy:38)

Stefan Bärthlein November 6, 2019

Same problem here, did you solve it?

Stefan Bärthlein November 6, 2019

seems like there has been some changes, in my former code I supposed

com.atlassian.servicedesk.api.requesttype.RequestTypeService.getRequestTypes to return a
com.atlassian.fugue.Either 

 so this faild although it was working before:

def requestTypes = requestTypeService.getRequestTypes(currentUser, requestTypeQuery)

return (requestTypes?.right?.results[0]?.getIssueTypeId()).toString()

 

just changed it to something like:

requestTypes?.findFirst()?.get()?.name

or

requestTypes?.each{ ... }

 

regards.

Suggest an answer

Log in or Sign up to answer