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.
showing 5 of 7
show 2 more comments
|
Accepted answer
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
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?
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);
|
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.
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 :)