Forums

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

service desk getting request type

Sergio Palacio August 17, 2018

I'm trying to get the service request in a validation script using scriprunner

But the script gets a different service than the chossen by the user.

 

@WithPlugin("com.atlassian.servicedesk")
RequestTypeService requestTypeService = ScriptRunnerImpl.getPluginComponent(RequestTypeService)

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

def reqQ = requestTypeService.newQueryBuilder().issue(issue.id).build()
def reqT = requestTypeService.getRequestTypes(currentUser, reqQ)
def requestTypeName = reqT.right.results[0].getName()
log.warn("REQUEST TYPE " + requestTypeName)

 

if (requestTypeName == "Alpha"){
blah
}


WARN [jira.groovy]: REQUEST TYPE Beta

thanks in advance.

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Mark Markov
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.
August 20, 2018

Hello @Sergio Palacio

try this script:



import com.atlassian.jira.component.ComponentAccessor

//service desk apis to get name instead of key value
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.atlassian.servicedesk.api.requesttype.RequestType
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.atlassian.servicedesk")

@PluginModule

RequestTypeService requestTypeService

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


RequestType getRequestType = requestTypeService.getRequestTypeForIssue(currentUser, issue).right().get()
String requestTypeName = getRequestType.getName()

log.warn("REQUEST TYPE NAME: ${requestTypeName}"
 
Sergio Palacio August 21, 2018 edited

Hi Mark.

Thanks for your answer.

requestTypeService.getRequestTypeForIssue is deprecated for the latests servicedesk version

Regards

Sergio Palacio August 21, 2018

chrome_2018-08-21_14-10-56.png

DevaKiran
Contributor
April 18, 2019

Then what is the alternative for it.

TAGS
atlassian, compass learning path, get the most out of compass, internal developer platform, devex learning path, atlassian learning, transparent architecture, component catalog, improve dev experience, compass platform training

Elevate your skills and enroll in the Compass learning path today! 💻

This learning path offers short, self-paced courses to help software teams systematically manage components and services. Compass provides a unified interface for tracking distributed software architecture and team collaboration.

Learn more!
AUG Leaders

Atlassian Community Events