How to delete link associated as related change request to a workitem?
Hi,
I had linked a Related Change Request to my workitem and the link is perfectly visible. But now I want to programmatically delete the link thus created on triggering some event. I am unable to find any programmatic way to delete the link created after linking Related Change Request to a workitem. Can someone please help me with the problem. Thanks in advance. |
One answer
Hi Bhushan,
Please try following method. public void removeLinks(IWorkItem source, IWorkItem target, IProgressMonitor monitor) throws TeamRepositoryException { IWorkItemClient workItemClient = (IWorkItemClient) ((ITeamRepository) source .getOrigin()).getClientLibrary(IWorkItemClient.class); IWorkItemWorkingCopyManager copyManager = workItemClient .getWorkItemWorkingCopyManager(); URI sourceURI = ItemURI.createWorkItemURI( workItemClient.getAuditableCommon(), source.getId()); URI targetURI = ItemURI.createWorkItemURI( workItemClient.getAuditableCommon(), target.getId()); IReference referenceTarget = IReferenceFactory.INSTANCE .createReferenceFromURI(targetURI); WorkItemWorkingCopy workingCopySource=copyManager.getWorkingCopy(source); workingCopySource.getReferences().remove(referenceTarget); workingCopySource.save(monitor); } Kindly acknowledge the result. Comments
bhushan punjabi
commented Aug 27 '14, 7:19 a.m.
Hi Ajay,
Rahul Singh Bhadauriya
commented Sep 12 '14, 6:15 a.m.
Hi Bhushan and Ajay,
|
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.