Welcome to the Jazz Community Forum
How do I create an included-in-build link from Java API ?

Accepted answer

IBuildResult buildResult = ...IWorkItem wi = ...IReferenceFactory refFactory = IReferenceFactory.INSTANCE;IReference source = refFactory.createReferenceToItem(buildResult);IReference target = refFactory.createReferenceToItem(wi);ILinkServiceLibrary linkServiceLibrary = ...ILink link = linkServiceLibrary.createLink(BuildLinkTypes.INCLUDED_WORK_ITEMS, source, target);linkServiceLibrary.saveLink(link);
Comments

Thanks that worked a treat :-)

Hi SEC, I used your example code to create some more consistent documentation here: http://rsjazz.wordpress.com/2012/09/20/the-rtc-workitem-server-link-api-linking-to-work-items-and-other-elements/ . Thanks so much for sharing!

Hi Sec,
I have a doubt here . At server side I need to create a link in defect WI of project Area 1 which will link it to story WI of project Area2. which approach is better? The above one you mentioned or the below one ? What difference these two approach have.
IWorkItemReferences references = workItemServer
.resolveWorkItemReferences(defect, null);
IReference wkRef = WorkItemLinkTypes.createWorkItemReference(storyWI);
IEndPointDescriptor storyEndpoint = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.TRACKS_WORK_ITEM).getTargetEndPointDescriptor();
references.add(storyEndpoint, wkRef);
Also all the link type in RTC are C/ALM type? I am very confused with the term CALM link ,can you please provide some information on the same.
Thanks & Regards,
Aastha

If you want to create tracks relationships, see https://rsjazz.wordpress.com/2015/02/27/a-rtc-workitem-command-line-version-2-2/
This implements it. It does this in the client API, but the server API looks the same, pretty much. It is important to get the order right and it is important to create the endpoint object right. You can not just take the URL that local WI-WI links have, but xou have to construct the URI in a different way.

I created some commandline tool, that can do this kind of linking as well. See https://rsjazz.wordpress.com/2015/02/27/a-rtc-workitem-command-line-version-2-2/

Hi Ralph,
Thanks for your reply. I went through some of your blogs about creation of CALM link ,which helped me in gaining knowledge about CALM links.
I have one question -- I noticed while creating CALM we use the URI. Is it mandatory? What is the reason behind creating CALM from the URIs?
Also my requirement is to create contributes to /track CALM between work items of two Project Area. If at all creating CALM link type via URI is not mandatory ,which approach should I follow in my case URI based or non-URI based?
Thanks & Regards,
Aastha

It is not a good practice to post additional questions to questions with accepted answers.
Please create your own question to ask about new topics. Although I could create a question from this one, I'd rather have the users to do so.
In general links use Locations to store information. There are different ways to create these Locations, resulting in different URI's. You need to use the correct way to create the locations to get the correct URI format to make the link work.
I find all that out, by looking at the data that is used/created in the tool and by trying to find out how to create that data.
Look into the source of https://rsjazz.wordpress.com/2015/02/27/a-rtc-workitem-command-line-version-2-2/ to understand the different ways to create locations. It covers Tracks/Contributes To.
RTC is based on URI's and REST, so you will end up with URI's. This is also needed to be able to reference objects from any application external to RTC.

Hi Ralph,
I am sorry for the inconvenience caused. I will follow this practise from now onwards.
Thanks for the information. It is very helpful!!
Thanks & Regards,
Aastha