It's all about the answers!

Ask a question

programmatically adding RELATED_ARTIFACT link doesn't work on client side


Susan Hanson (1.6k2184193) | asked Jan 06 '15, 1:04 p.m.
 I am attempting to add a RELATED_ARTIFACT link to a set of work items using the RTC Java Client APIs.  The same code (or almost the same code) works fine via a Server-side plugin.

However, when this runs, nothing is added, but no errors occur either.

It uses a WorkItemOperation, which then calls this:
private void addMyLink(WorkItemWorkingCopy workingCopy) throws TeamRepositoryException, URISyntaxException {
String URL = "http://<my_valid_url>";
IWorkItemClient _service = myRepository.getWorkItemClient();
IWorkItemReferences references = _service.resolveWorkItemReferences((IWorkItemHandle) workingCopy.getWorkItem().getItemHandle(), null); //this is basically the only line changed, since I need the workItemHandle, which my execute() method of the WorkItemOperation gets the workingCopy only
IURIReference reference = IReferenceFactory.INSTANCE.createReferenceFromURI(new URI(URL), "Current Template", "ODP Format");
references.add(WorkItemEndPoints.RELATED_ARTIFACT, reference);
//the save occurs just by dropping out of this since it is a WorkItemOperation, which differs from the Server-Side action which requires a call to save the work item.
}

Does anybody know offhand why this is not working?  As I mentioned, no errors and I can debug and actually get through that it is calling these, and looking at the "reference" variable looks okay also.


Comments
Zaid Al-Khishman commented Jan 06 '15, 2:32 p.m. | edited Jan 06 '15, 2:45 p.m.

Can you edit the workItem via the same plugin? (e.g change the description)

I have also managed to do this via server-side. Luckily though https://jazz.net/wiki/bin/view/Main/ProgrammaticLinkCreation this link here describes how you could do that via the client. It does look like you need to call

linkManager.saveLink(link, monitor);

Be the first one to answer this question!


Register or to post your answer.