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

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

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.

0 votes

Comments

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?

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)


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

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.

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.

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.

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

0 votes


One other answer

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

0 votes

Comments

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

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 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,938

Question asked: Jan 08 '14, 10:44 a.m.

Question was seen: 7,396 times

Last updated: Jan 10 '14, 12:44 p.m.

Confirmation Cancel Confirm