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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,553,465
Community Members
 
Community Events
184
Community Groups

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

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

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
AUG Leaders

Atlassian Community Events