API to duplicate an WorkItem
There is a menu option to duplicate an workitem, but I didn't found any API method related to that.
Is there any method to duplicate an workitem or I have to copy attribute by attribute? (including the customs ones) |
3 answers
I'm not aware of any copy/duplicate method; however, there is an internal CopyToProjectOperation class in com.ibm.team.workitem.common.internal. Similarly there's the CopyToProjectAreaOperation class in com.ibm.team.workitem.rcp.ui.internal.wizards. The latter is the one behind the UI move/copy operation.
|
There is no method provided. It is not straightforward to copy a work item, especially if you copy that work item into a different project area ( you will have to resolve the attributes by identifier ).
Here is a starting point to copy the attributes: <pre> IAuditableClient auditableClient= (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class); IWorkItemCommon workItemCommon= (IWorkItemCommon) teamRepository.getClientLibrary(IWorkItemCommon.class); fType= workItemCommon.findWorkItemType(<workItem>.getProjectArea(), <workItem>.getWorkItemType(), monitor); fType.getCustomAttributes(); workItemCommon.findBuiltInAttributes(<workItem>.getProjectArea(), monitor); </pre> That will get you all the attributes. Note, not all can be copied (e.g. the Id). Additionally, if you copy the work item over project areas, you will have to resolve the id over the new project using: <pre>workItemCommon.findAttribute(projectArea, identifier, monitor)</pre> Finally, the comments will have to be copied separately. I know its not pretty, but it can be done cleanly |
Thanks Guys. I appreciate your feedback. I am working on implementing per your suggestions.
Jared.
|
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
Hi. Would someone please reply to this post? I have the same question.
If there is no "duplicateWorkItem()" method, then what's the best way to copy a work item?
Thanks.