It's all about the answers!

Ask a question

RTC: how to retrieve work item type "name" via Java API

Luca Martinucci (1.0k396112) | asked Dec 05 '14, 9:43 a.m.
Is it possible to retrieve, via Java API, the "user-readable" type name of a work item?
I mean: suppose you have a Project Change Request.
Its type is "projectchangerequest" (as it is retrieved from the workItem.getWorkItemType() method; this is the work item type "id"), but, on the form, it is displayed as "Project Change Request" (this is the work item type "name").
I need to retrieve this "name", but I cannot figure out how.
Any suggestions?
My RTC version is 4.0.6

Accepted answer

permanent link
Ralph Schoon (63.2k33646) | answered Dec 05 '14, 10:45 a.m.
IWorkItemType.getDisplayName() ?
Luca Martinucci selected this answer as the correct answer

Luca Martinucci commented Dec 09 '14, 6:18 a.m.

Thanks for the suggestion

3 other answers

permanent link
Rajiv Gandhi (34812) | answered Jun 16 '15, 11:31 a.m.
Thanks to both of you.
this method is working fine and it has full filled my requirement 

permanent link
Rajiv Gandhi (34812) | answered Jun 15 '15, 5:05 a.m.
Hi Luca,

I tried to get workitem id and set into one of attribute using below script but it is not working. Please correct me if it is wrong script.


dojo.require(""); // To access the work item attributes
dojo.require(""); // To create a status object to return
dojo.require(""); // To create a severity for the status

(function() {

    dojo.declare("workitemtype", null, {

        getValue: function(attributeId, workItem, configuration) {              
        IWorkItem workItem = .....;
        String workItemTypeID = workItem.getWorkItemType();
    return workItemTypeID;




Luca Martinucci commented Jun 15 '15, 5:57 a.m.

Rajiv, it looks like you are writing a Javascript attribute customization.
Instead, I developed a Java extension (plugin).
So, my code won't work in your script.
I cannot help you, because I've never done such a thing with javascript.

Ralph Schoon commented Jun 15 '15, 6:06 a.m.

Please file your own question next time, as this is already closed and for Java API. Thanks.

Please carefully read: especially

Consider also to do the

Process Enactment Workshop for the Rational solution for Collaborative Lifecycle Management

From the first link you get that the JavaScript API syntax is:


permanent link
Rajiv Gandhi (34812) | answered Jun 14 '15, 11:13 a.m.

How do i get only workitem type id via java api?. Could you please let me know the complete syntax of this or Sample code?. 


Luca Martinucci commented Jun 15 '15, 3:51 a.m.

In order to retrieve the work item type id, you need a IWorkItem object, then you call the getWorkItemType method (look at my original post):

IWorkItem workItem = .....;
String workItemTypeID = workItem.getWorkItemType();

If you instead need the work item type name, I retrieve it with these code:

String workItemTypeName = "";
IWorkItemCommon workItemCommon = getService(IWorkItemCommon.class);
List<IWorkItemType> workItemTypes = workItemCommon.findWorkItemTypes(projectAreaHandle, null);
Hashtable<String, String> typesToNames = new Hashtable<String, String>();
for (IWorkItemType workItemType : workItemTypes) {
    typesToNames.put(workItemType.getIdentifier(), workItemType.getDisplayName());
String workItemType = workItem.getWorkItemType();
if (typesToNames.containsKey(workItemType)) {
    workItemTypeName = typesToNames.get(workItemType); 

Be aware that in a P.A. you can have 2 different work item types with the same name, but different IDs.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.