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

How to get CustomerRequestType of an issue?

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
December 5, 2017

I am trying to get CustomerRequestType name of an issue (that is introduced by Jira Service Desk)

When I get the custom field value of request type like any other custom field, I get a string like "sam/newsoftware". What I need to get is the actual name. Something like "New Software".

Tried autowire. Does not find a suitable cadidate. Tried getting my hands ın CustomerRequestTypeService object through ComponentAccessor. No luck.

Any suggestions about how to get the request type name?

1 answer

1 vote
miikhy
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.
December 5, 2017

Hi Emre,

There's a Service Desk class which is able to give you the name (displayed name) of a Customer Request type in JSD: https://docs.atlassian.com/jira-servicedesk/3.9.0/com/atlassian/servicedesk/api/requesttype/RequestType.html

You can use the associated builder from the issue ID to retrieve the associated Requesttype object and use the getName() method:

https://docs.atlassian.com/jira-servicedesk/3.9.0/com/atlassian/servicedesk/api/requesttype/RequestTypeQuery.Builder.html

Hope this helps!

Cheers

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
December 5, 2017

Hi Micky, Thank you.

Looks promising but I couldn't get it to work.

RequestTypeQuery and RequestTypeQuery.Builder are interfaces and mighty Atlassian documentation does not give information about classes who implement this interface. I browsed through the IDE and found a class named RequestTypeQueryImpl. This class is an internal api class (com.atlassian.servicedesk.internal.feature.customer.request.requesttype.RequestTypeQueryImpl) so I guess it is not meant for our use but also has a static build() method that returns an instance so once again, promising.

The problem is I cannot get that instance. I get a NoClassDefFoundErro exception at runtime. (I am developing on a Jira 7.5 with JSD 3.8.1) Documentation says the class is available in JSD 3.8 or even JSD 3.7 but no luck.

miikhy
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.
December 6, 2017

Hi Emre,

You'll have to use OSGi (https://bitbucket.org/atlassian/atlassian-spring-scanner?_ga=2.103863168.1093982757.1511790277-572295793.1506609124) to inject the RequestTypeQuery object I guess. To be honest I did not try it but should work with an inject. I'm using the PluginLicenseManager interface for my plugin and it's also an interface. Once injected, methods are usable and should give you the ability to use the API :)

Let me know if you manage to get it working!

Cheers

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
December 8, 2017

Hi Micky,

Thank you for the direction.

The document you sent has instructions for 2.x+ version of Spring Scanner. It turns out my plugin uses the older version so I have several <component-import> statements in my atlassian-plugin.xml file.

I added the interface I need into atlassian-plugin.xml, like ... 

<component-import key="requestTypeQueryService" interface="com.atlassian.servicedesk.api.requesttype.RequestTypeQuery"/>

No compile-time errors but when when enabling the plugin on Jira after upload, Jira waits for 300 seconds and I get :

org.springframework.context.ApplicationContextException: Application context initialization for 'blah blah' has timed out waiting for (objectClass=com.atlassian.servicedesk.api.requesttype.RequestTypeQuery)

 The same happens for the interface you suggested: RequestType.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events