It's all about the answers!

Ask a question

API to duplicate an WorkItem


Eduardo Bello (4401922) | asked Mar 22 '11, 8:33 a.m.
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)

Comments
Jared Camilli commented Jun 04 '12, 2:07 p.m.

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.

3 answers



permanent link
Luan Doan-Minh (2423) | answered Jun 04 '12, 2:46 p.m.
JAZZ DEVELOPER
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.

permanent link
Filip Wieladek (30413) | answered Jun 04 '12, 3:01 p.m.
edited Jun 04 '12, 3:01 p.m.
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

permanent link
Jared Camilli (112) | answered Jun 04 '12, 4:44 p.m.
Thanks Guys. I appreciate your feedback. I am working on implementing per your suggestions.

Jared.

Your answer


Register or to post 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.