It's all about the answers!

Ask a question

How do I retrieve potential duplicates of a work item

Petcharat Viriyakattiyaporn (4113) | asked Jul 20 '08, 2:44 p.m.

I would like to be able to retrieve potential duplicates of a work item programmatically, as is done by the context menu "Find Potential Duplicates". I used the following code snippet to do that:

IWorkItemWorkingCopyManager manager = workItemClient.getWorkItemWorkingCopyManager();
manager.connect((IWorkItemHandle) sourceItem.getItemHandle(), IWorkItem.FULL_PROFILE, null);
sourceWorkingCopy = manager.getWorkingCopy((IWorkItemHandle) sourceItem.getItemHandle());

IWorkItemReferences references = sourceWorkingCopy.getReferences();

List<IReference> duplicates = references.getReferences(WorkItemEndPoints.DUPLICATE_WORK_ITEM);

// Check whether 'duplicates' is empty. If so, do:
duplicates = references.getReferences(WorkItemEndPoints.DUPLICATE_OF_WORK_ITEM);

I expected that 'duplicates' wouldn't be empty because when I executed "Find Potential Duplicates" on the source work item via the GUI, it returned some work items that have similar description. However, with the code above, the 'duplicates' list turned out to be empty. So, I suspected that

only returns the duplicates that are explicitly created as duplicates.

So, what is another way to retrieve potential duplicates? Your help will be appreciated.


One answer

permanent link
Work Item & UI Commons Team (1.3k1) | answered Jul 21 '08, 3:58 a.m.

you can take a look at, IWorkItem, boolean) which is used from the "Find potential duplicates" action. It creates an Expression for a duplicate search and sends it to the server for evaluation. Using work item references will - as you already found out - only return explicit duplicates, but not potential ones. To receive potential duplicates, a fulltext query is executed on the server.

Foundation & Work Item Team

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.