It's all about the answers!

Ask a question

How to get the "Found In" field from an RTC "defect" type Work Item? Using the Java API


Minghua Zhao (2122) | asked Jan 08 '14, 10:44 a.m.
I'm fairly new in working with the API.

I've been trying to get the "Found In" field from an RTC work item by accessing the Work Item's Custom Attributes. Strangely, it did not show in the custom attributes.

I'm trying to figure out a way of getting the information from the Work Item. For example (this doesn't actually work)

IAttribute foundInAttribute = myWorkItemClient.findAttribute(projectAreaHandle, "foundIn", null);
                Object foundIn = currentWI.getValue(foundInAttribute);
                System.out.println("Found iN!!!" + foundIn.toString());


Thanks.

Comments
Ralph Schoon commented Jan 08 '14, 11:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

In addition to Susan, you might want to look into https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ and the posts it points to for some more information.

You need the ID of the attribute and you want to make sure the work item actually has this attribute as well (for custom attributes at least).

You should try to use the ID's that are presented in the process configuration. The id "foundIn" used to be as an internal ID and I am actually wondering why you don't get the attribute. what is your error message?


Minghua Zhao commented Jan 08 '14, 12:03 p.m.

So, running the code that I have posted above,
I get this:

Found iN!!!com.ibm.team.workitem.common.internal.model.impl.DeliverableHandleImpl@47fd47fd (stateId: [UUID _2HRlgD19EeOaCKbotV-cjA], itemId: [UUID _GHpZoM7LEeGTDftJfIlDZQ], origin: com.ibm.team.repository.client.internal.TeamRepository@57715771, immutable: true)



Minghua Zhao commented Jan 08 '14, 12:06 p.m.

Apparently, it does fetch something, but it doesn't help a lot..


Minghua Zhao commented Jan 08 '14, 1:50 p.m.

Hi Ralph, I've read your blog entry. I suppose now its a matter of knowing how to cast the returned object.

I've tried DeliverableHandle, and getting "getFullState", but strangely it returns Null.

What are the different ways of casting returned Objects? I'm not sure what to do.


Ralph Schoon commented Jan 09 '14, 1:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Read the blog posts related to the one below. Especially Setting up and https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/

I think you want to cast to IDeliverable. By debugging and is instance of operations you can find out what you need.


Ralph Schoon commented Jan 09 '14, 1:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If you get a handle, you want to resolve it. Read https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ for how to do that.


Minghua Zhao commented Jan 10 '14, 12:44 p.m.

Thanks Ralph.
I've figured out the answer... I've included it below as well in case future folks are interested :)

showing 5 of 7 show 2 more comments

Accepted answer


permanent link
Minghua Zhao (2122) | answered Jan 10 '14, 12:42 p.m.
ah ha, got it.

IAttribute foundInAttribute = myWorkItemClient.findAttribute(projectAreaHandle, "foundIn" , null);
                IDeliverableHandle foundInDeliverableHandle = (IDeliverableHandle) currentWI.getValue(foundInAttribute);
                if (foundInDeliverableHandle != null){
                    IDeliverable deliverable = (IDeliverable) this.repository.itemManager().fetchCompleteItem(
                            foundInDeliverableHandle, IItemManager.DEFAULT, null);
                }
Ralph Schoon selected this answer as the correct answer

One other answer



permanent link
Susan Hanson (1.6k2201194) | answered Jan 08 '14, 10:54 a.m.
I assume you are looking for the Built-in attribute with name Found In, and if so, you may need to use "com.ibm.team.workitem.attribute.version" as the attribute ID.  I've never actually tried to get that myself, but looking at some of my work items, that is the attribute ID for the attribute named "Found In".

Susan

Comments
Minghua Zhao commented Jan 08 '14, 11:47 a.m.

I'm sorry, how do I use the attribute ID? Or get access to it?
Is it an argument to some function?


Ralph Schoon commented Jan 08 '14, 11:57 a.m. | edited Jan 08 '14, 11:58 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

myWorkItemClient.findAttribute(projectAreaHandle, "foundIn", null);

The boldface text is the argument for the attribute ID. You have to look it up in the process configuration, or you have to use the methods to get the built in or the other attributes. Please look at the blog mentioned above.

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.