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.
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.
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);
}
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);
}
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
Susan
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.
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Jan 08 '14, 11:35 a.m.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
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
Jan 08 '14, 12:06 p.m.Apparently, it does fetch something, but it doesn't help a lot..
Minghua Zhao
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
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Jan 09 '14, 1:43 a.m.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
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Jan 09 '14, 1:45 a.m.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
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 :)