IWorkItemCommon.findAttribute not working for built-in attributes
![]()
I'm writing a tool which should later import workitems from a text file. to get to know how to work with the jazz java api, I made a little test application
I can dynamilcally set the custom attributes of a custom work item type by passing the id and the value. but this procedure fails if i want to set a built-in attribute like the work item description.
the method findAttributes does return null for all built-in attributes, but works for all my custom attributes (I tried it with various fields with different data types).
Does findAttributes only work for custom attributes?
Below the code of my (simplified) application
EDIT: for some reason, " string, string " is shown as " string, string="" ", i have no idea why
String workItemSummary = "this is my summary"; // get the category handle // define key/value pairs for custom attributes // initialize the work item // save the work item and return the id of the saved work item
Work Item Initialization:
private static class WorkItemInitialization extends WorkItemOperation { |
2 answers
![]()
Ralph Schoon (62.3k●3●36●43)
| answered Oct 25 '13, 3:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
This has always worked for me. See https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ and use the interface IWorkItem to get the correct ID's e.g.
IWorkItem.DURATION_PROPERTY
Comments Hi Ralph
Does it work for you if you pass "com.ibm.team.workitem.attribute.description" instead of IWorkItem.DURATION_PROPERTY?
To make my importer dynamic, I want to achieve it with the ID of the attribute
The values (attributeValueList) shall be read dynamically in the future, so it would be easier if I could use the ID (in string format) instead of mapping the ID to the different interface properties (e.g. IWorkItem.DURATION_PROPERTY) I believe I have successfully done that. I have no time to test it for you. I would try to check the value of the IWorkItem attribute ID, you can pass that. To evaluate your code works at all, I would start with the IWorkItem interface. Make sure it works and then stat looking at ID Strings.
The code works for me except for the built-in attributes when i pass the ID. So in the example above, the work item is being created with summary, category and managementaction set.
IAttribute myAttribute2 = fWorkItemClient.findAttribute(fProjectArea, IWorkItem.DESCRIPTION_PROPERTY, monitor);
workItem.setValue(myAttribute2, "my description");
could that be a bug in the interface?
Or is "com.ibm.team.workitem.attribute.description" not the same as IWorkItem.DESCRIPTION_PROPERTY?
|
![]()
I have found the solution. The string ID of the built-in attributes are different than those ID's which are shown in the jazz eclipse client.
To find out the ID do the following:
- Open the project area in the eclipse client
- Choose 'Process Configuration' tab
- Navigate to Project Configuration -> Configuration Data -> Work Items -> Types and Attributes
- click a built-in attribute and choose Edit
- instead of the whole ID path (like 'com.ibm.team.workitem.attribute.modified'), only use the last part ('modified').
---> for custom attributes, you have to use the whole path (like in the source code above)
I don't know if that is a bug or feature, but in my opinion, it is kind of confusing.
Comments From my personal perspective, I would consider this a defect - the ID's presented in the UI should be the ones that work. I remember I had similar issues in the past, but I am unsure if I could solve this to use the full ID's.
the related defect is resolved as 'wont fix', so my answer is still valid ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
@lukas, I had forgotten but I filed a similar defect aeons ago. It is still alive, I think. You can not use the external ids from the eclipse client. You have to use the internal ones from the web UI. Note, the WCL has a command to print the real ids for the built in and custom attributes of a type. |