Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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)

0 votes

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.



3 answers

Permanent link
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.

1 vote


Permanent link
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

1 vote


Permanent link
Thanks Guys. I appreciate your feedback. I am working on implementing per your suggestions.

Jared.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,950

Question asked: Mar 22 '11, 8:33 a.m.

Question was seen: 5,525 times

Last updated: Jun 04 '12, 4:44 p.m.

Confirmation Cancel Confirm