I need to get the list of fields defined on a Request Type. I assume that I use RequestTypeFieldService but I can’t find any way to instantiate it so that I can query the request type definition.
I am using ScriptRunner and have tried to instantiate using @WithPlugin and @PluginModule to instantiate the service. I get the following error in the log:
Cant find plugin module or OSGi service for class: com.atlassian.servicedesk.api.field.RequestTypeFieldQuery
Apparently, there is no implementation?
This works fine.
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.atlassian.servicedesk.api.field.RequestTypeFieldService
import com.atlassian.jira.component.ComponentAccessor
@WithPlugin('com.atlassian.servicedesk')
@PluginModule
RequestTypeService requestTypeService
@PluginModule
RequestTypeFieldService requestTypeFieldService
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def requestTypesForAServiceDesk = requestTypeService.getRequestTypes(
loggedInUser,
requestTypeService.newQueryBuilder()
.serviceDesk(6)
.build()
)
def oneSpecificRequestType = requestTypesForAServiceDesk.first()
def requestTypeCreateMeta = requestTypeFieldService.getCustomerRequestCreateMeta(
loggedInUser,
requestTypeFieldService.newQueryBuilder()
.serviceDesk(6)
.requestType(oneSpecificRequestType.id)
.build()
)