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

Get possible values for Customer Request Type via script runner in Service Desk > v3.3

Thomas Heidenreich
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.
February 9, 2017

With the last Service Desk update the content of the Customer Request Type fields have changed from "desk/general-help" to "desk/e968b227-666d-45f4-867a-2f289c22318f"

I couldn´t find a way to determine the valid options for a given issue (using getOptions from the regular API just returns an empty array).

Does anyone have an idea about how to archive this? My last resort would be looking it up in the database - but there should be an easier way...

Thanks in advance
Thomas

ps: Some explaination of the usecase:

  • Customer opens a service desk request as a bug
  • Agent sees that it is actually a feature request and changes the issue type (and forgets to update the request type)
  • Now the customer does not see the issue anymore as the Request Type is empty
    ==> We have to set a valid request type via script

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Thanos Batagiannis _Adaptavist_
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.
February 10, 2017

Hi Thomas,

Try in your script console (using the Service Desk API)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.portal.PortalService
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.atlassian.servicedesk")

@PluginModule
RequestTypeService requestTypeService

@PluginModule
PortalService portalService

def serviceDeskIssueKey = "SD-1"
def serviceDeskIssue = ComponentAccessor.getIssueManager().getIssueByCurrentKey(serviceDeskIssueKey)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def requestTypes = requestTypeService.getAllRequestTypes(user)

if (requestTypes.isLeft()) {
    log.error "${requestTypes.left().get()}"
    return
}

if (!serviceDeskIssue)
    return

def portalRequest = portalService.getPortalForProject(user, serviceDeskIssue.projectObject)

if (portalRequest.isLeft()) {
    log.debug "Error ${portalRequest.left().get()}"
    return
}

def portal = portalRequest.right().get()

return requestTypes?.right()?.get()?.findAll {it.issueTypeId == serviceDeskIssue.issueTypeId as Long && it.portalId == portal.id}?.collect {
    "Request type: ${it.name} | ID: ${it.id} | Description: ${it.description}}"
}?.join("<br>")

Please let me know if this does the trick.

regards, Thanos

Thomas Heidenreich
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.
February 10, 2017

Thanks Thanos,

that gives me a list of all (71) request types names, IDs and descriptions across all service desk projects. The valid values are not included and the right project isn´t selected, but it points me to the right direction.

What I probably want is calling validValues() on the RequestTypeField object - but at the moment  I cannot find a way to get the right instance of the object sad

Do you have any ideas
Thomas

Thanos Batagiannis _Adaptavist_
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.
February 10, 2017

Hey Thomas, 

Updated the script above to take into consideration the project. Regarding the validity I am still searching (fairly new to Service Desk JAVA API) ...

Larry Wilson July 26, 2017

when I try this I just get:

2017-07-26 07:02:42,866 WARN [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingPropertyException: No such property: event for class: Script3 at Script3.run(Script3.groovy:10)

all (it.*) are highlighted in red on the return line

Any guidance would be appreciated

TAGS
AUG Leaders

Atlassian Community Events