It's all about the answers!

Ask a question

Serverside create link from a WorkItem to a Changeset

erling jorgensen (40911) | asked Jul 20 '12, 6:54 a.m.

My task is to create a link between a Workitem and a changeset in a Participant on delivery. I have access to both the workitem and the changeset, and I am able of establishling a link, but the link is not registered as link to a Changeset.

My code looks like this:

IWorkItemServer workItemservice = this.getService(IWorkItemServer.class); 
IWorkItem workItemWC = (IWorkItem) workItem.getWorkingCopy();
IWorkItemReferences references = workItemservice.resolveWorkItemReferences(workItemWC, monitor);
IReference reference= IReferenceFactory.INSTANCE.createReferenceToItem(changeSet.getWorkingCopy().getItemHandle());

references. add(WorkItemEndPoints.RELATED_ARTIFACT, reference);
workItemservice.saveWorkItem2(workItemWC, references, null);

I do get a reference created, but as is actually says on the WorkItemEndPoints.RELATED_ARTIFACT, only as a related artifact. How do I make i proper reference to a Changeset?

Thx in advance


Accepted answer

permanent link
erling jorgensen (40911) | answered Jul 24 '12, 7:47 a.m.

I think I've solved it myself. This code does the trick:

ILinkService linkService = getService(ILinkService.class);
ILinkServiceLibrary ls = (ILinkServiceLibrary) linkService.getServiceLibrary(ILinkServiceLibrary.class);
IReference changeReference= IReferenceFactory.INSTANCE.createReferenceToItem(changeSet.getItemHandle());
IReference workItemReference= IReferenceFactory.INSTANCE.createReferenceToItem(workItemWC.getItemHandle());
ILink il = ls.createLink(WorkItemLinkTypes.CHANGE_SET, changeReference, workItemReference);

Maybe somebody else but me can use it.

Ralph Schoon selected this answer as the correct answer

Ralph Schoon commented Jul 24 '12, 8:23 a.m.

Thanks for sharing Erling.

Ralph Schoon commented Sep 20 '12, 11:48 a.m.

Robert Carter commented Sep 24 '14, 10:02 a.m.

What did you include in your plug-in.xml file?  I keep getting this error when I try to run my participant.
CRJAZ1115I The "" service was not registered.  I have the following pre-requisites:
<requiredService interface="" />
                    <requiredService interface="" />
                    <requiredService interface="" />

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.