Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

service desk getting request type

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

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}"
 

Hi Mark.

Thanks for your answer.

requestTypeService.getRequestTypeForIssue is deprecated for the latests servicedesk version

Regards

Then what is the alternative for it.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Asked in Jira Service Desk

Calling all Insight users, we need your help!

Hello Insight users,  As part of our (Mindville's) acquisition by Atlassian, our training team is looking to build some new Insight training materials. It would really helpful if you can ...

97 views 1 0
View question

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you