It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get CustomerRequestType of an issue?

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

0 votes
miikhy Community Leader Dec 05, 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

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 Community Leader Dec 06, 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

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
Community showcase
Published in Jira Service Desk

[ Survey ] What does the future of ITSM look like? Take our survey today!

Hi all! We’re interested in learning more about your ITSM practices - what’s the current state of your ITSM practices? What are your aspirations for your IT team in the future? Which ITSM trends ar...

232 views 1 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you