Hello,
In the Jira Server project Service Desk we have several hidden request types (without groups). One of them is "IT help":
Using Java API in ScriptRunner Console I try to get the list of all request types including hidden ones.
I use the following script:
import com.atlassian.servicedesk.api.ServiceDeskManager
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.atlassian.servicedesk.api.field.RequestTypeFieldService
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
@WithPlugin("com.atlassian.servicedesk")
@PluginModule RequestTypeService requestTypeService
@PluginModule RequestTypeFieldService requestTypeFieldService
@PluginModule ServiceDeskManager serviceDeskManager
def serviceDesk = serviceDeskManager.getServiceDeskForProject(Projects.getByKey("ABC"))
def query = requestTypeService.newQueryBuilder()
.serviceDesk(serviceDesk.id)
.build()
def requestTypesResult = requestTypeService.getRequestTypes(Users.loggedInUser, query)
def requestTypes = requestTypesResult.results
requestTypes*.name.contains("IT help")
It returns false.
In the list of requestTypes*.name there is not "IT help" too.
I read the javadoc https://docs.atlassian.com/jira-servicedesk/4.20.28/com/atlassian/servicedesk/api/requesttype/RequestTypeQuery.Builder.html and found the method filterHidden(Boolean filter) and used it in the script:
import com.atlassian.servicedesk.api.ServiceDeskManager
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.atlassian.servicedesk.api.field.RequestTypeFieldService
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
@WithPlugin("com.atlassian.servicedesk")
@PluginModule RequestTypeService requestTypeService
@PluginModule RequestTypeFieldService requestTypeFieldService
@PluginModule ServiceDeskManager serviceDeskManager
def serviceDesk = serviceDeskManager.getServiceDeskForProject(Projects.getByKey("ABC"))
def query = requestTypeService.newQueryBuilder()
.serviceDesk(serviceDesk.id)
.filterHidden(true)
.build()
def requestTypesResult = requestTypeService.getRequestTypes(Users.loggedInUser, query)
def requestTypes = requestTypesResult.results
requestTypes*.name.contains("IT help")It also returns false.
I tried the same script with .filterHidden(false) - no luck.
At the same time search by non-hidden request type returns true.
I have admin role in the project and in the whole Jira.
Am I doing something wrong?
Or is it a bug? Is there any workaround to get hidden request types acepts using REST API which also has limitations https://support.atlassian.com/jira/kb/get-requesttype-jsm-rest-operation-doesnt-fetch-hidden-request-types/ ?
I found the answer myself.
There is not need to filter request types. Initial script returns paged results which contain all request types including hidden ones. So I used
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.