It's all about the answers!

Ask a question

How to delete link associated as related change request to a workitem?


bhushan punjabi (1645) | asked Aug 27 '14, 6:28 a.m.
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



permanent link
Ajay Mallikarjunaiah (148410) | answered Aug 27 '14, 7:11 a.m.
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,
Thanks for your answer and really appreciate such a quick response. Apologies for asking programmatic way of doing the thing. I was just wondering can we do the same using web based rest client (like that of Mozilla Rest Client) by firing some delete query to workitem for deleting link? 


Rahul Singh Bhadauriya commented Sep 12 '14, 6:15 a.m.

Hi Bhushan and Ajay,
As per my understanding bushan is looking for removing the relatedChangeRequest from the workitem using the OSLC REST Services.
I am also interested to see how can we do the same using the OSLC REST API in RTC.
Thanks,
Rahul

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.