Serverside create link from a WorkItem to a Changeset
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);
Accepted answer
ILinkService linkService = getService(ILinkService.class);
Maybe somebody else but me can use it.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);ls.saveLink(il);
Comments
Thanks for sharing Erling.
Hi Erling, I used your input and the input from https://jazz.net/forum/questions/82384/serverside-create-link-from-a-workitem-to-a-changeset to create some working code and summarized in http://rsjazz.wordpress.com/2012/09/20/the-rtc-workitem-server-link-api-linking-to-work-items-and-other-elements/ . Thank you so much for the example.
What did you include in your plug-in.xml file? I keep getting this error when I try to run my participant.
CRJAZ1115I The "com.ibm.team.links.common.factory.IReferenceFactory" service was not registered. I have the following pre-requisites:
<requiredService interface="com.ibm.team.links.common.service.ILinkService" />
<requiredService interface="com.ibm.team.links.service.ILinkServiceLibrary" />
<requiredService interface="com.ibm.team.links.common.factory.IReferenceFactory" />