How to get the list of required attributes that needs to be setted by creating a new work item RTC Java API?
Hello,
In my Java client application, I need to create a lot of new Work Items. I have two repositories and several projects area on them, and for each project there are the different fields (attributes) that are required to be set by creating new item. So, here is my question from the topic: is there a way to get list of required attributes from specified project? Thank you, Kamil |
Accepted answer
Ralph Schoon (63.6k●3●36●46)
| answered Jun 15 '15, 8:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can find it in the work item common (and server)
IWorkItemCommon.findRequiredAttributes(workItem, workflowAction, monitor) You can also find the read only attributes there. Kamil Dudek selected this answer as the correct answer
Comments
Kamil Dudek
commented Jun 15 '15, 8:44 a.m.
Thank you for your answer! So, can I get the instance of IWorkItemCommon from server using ITeamRepository.getClientLibrary(Class arg)? Could you also tell me, what is the workflowAction? Maybe this question are silly, but I'm only beginning developing in that API :)
Yes, in the Client API you get the client library. In the server API you get the IWorkItemServer with an analog call.
Like in https://rsjazz.wordpress.com/2016/07/15/build-on-state-change-work-item-save-participant/ you use com.ibm.team.repository.service.AbstractService as superclass and then you use getService()
|
2 other answers
hi kamil, i dont know, how to get list of required attributes but you can try to read this topic: https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ its maybe help you...
other way: i have 2 ideas about this topic 1- u can handle error in your java api and set the attribute one by one... for example: error message: you can set the summary if it is set the summary i think it is bad idea :) 2- u can list the required fields manuel for each project area (just 1 times) and use this list in your code...
if required attributes changing in time maybe you can try to save the list as xml or config file and read in your java code easyly.
|
Adding a snippet (plain java api)
(IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class); |
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.