Forums

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

trying to get customer request type

Sergio Palacio January 7, 2019

Hello.

I'm trying to get the customer request type and copy the string value id to a custom field. In the create postfunction

I have the following code.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.issue.fields.CustomField

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

@WithPlugin("com.atlassian.servicedesk")

def requestTypeService = ComponentAccessor.getOSGiComponentInstanceOfType(RequestTypeService)
def reqQ = requestTypeService.newQueryBuilder().issue(issue.id).build()
def reqT = requestTypeService.getRequestTypes(currentUser, reqQ)
String requestType = reqT.right.results[0].getName()
def cf_portal = customFieldManager.getCustomFieldObjectByName("portal");
issue.setCustomFieldValue(cf_portal, requestType)


The code does't have any error.

but when I trying to create a ticket from the portal. I select the ALPHA request Type.
But the cf_portal is filled with the GAMMA resquet type.

I don't know hot to get the correct request type. maybe ¿¿¿the query is not the correct???


thanks in advance.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events