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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.