Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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

0 votes


Accepted answer

Permanent link
IWorkItemType.getDisplayName() ?
Luca Martinucci selected this answer as the correct answer

1 vote

Comments

Thanks for the suggestion


3 other answers

Permanent link
Dears,

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?. 

Thanks,
Rajiv

0 votes

Comments

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.


Permanent link
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.

FYI,

dojo.provide("workitemtype");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // To access the work item attributes
dojo.require("com.ibm.team.workitem.api.common.Status"); // To create a status object to return
dojo.require("com.ibm.team.workitem.api.common.Severity"); // 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;
      }

    });

})();


Thanks,
Rajiv

0 votes

Comments

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.

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

Please carefully read: https://jazz.net/wiki/bin/view/Main/AttributeCustomization especially https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript

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:

workItem.getValue(WorkItemAttributes.TYPE);
    


Permanent link
Thanks to both of you.
workItem.getValue(WorkItemAttributes.TYPE); 
this method is working fine and it has full filled my requirement 

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,926

Question asked: Dec 05 '14, 9:43 a.m.

Question was seen: 8,313 times

Last updated: Jun 16 '15, 11:32 a.m.

Confirmation Cancel Confirm