[英]How to create a link between two work items programmatically for tfs in javascript?
I'm doing some programming for TFS 2015, and I have two work items that I need to add a link between. 我正在为TFS 2015进行一些编程,我有两个工作项目需要在两者之间添加链接。 I have both work items called, and both of their ids;
我既有两个工作项目,又有两个ID。 However, I can't figure out how to add the new link.
但是,我不知道如何添加新链接。 Does anyone know how to, or have any helpful resources I can use?
有人知道如何使用或有任何有用的资源吗?
You need to define what type of link to add by using WorkItemLinkTypeEnd Class , then add the link as related link by using RelatedLink Class . 您需要使用WorkItemLinkTypeEnd Class定义要添加的链接类型,然后使用RelatedLink Class将链接添加为相关链接。
Here is a .net example in this blog , you may refer to it: 这是此博客中的.net示例,您可以参考它:
try
{
LinkTypeItem type = combo_types.SelectedItem as LinkTypeItem;
int from_wit = Convert.ToInt32(txt_wit_from.Text);
int to_wit = Convert.ToInt32(txt_wit_to.Text);
WorkItem from = store.GetWorkItem(from_wit);
//Define what type of link to add.
//Child, Parent etc…
WorkItemLinkTypeEnd linkTypeEnd = store.WorkItemLinkTypes.LinkTypeEnds[type.ReverseEnd.Name];
//Add the link as related link.
from.Links.Add(new RelatedLink(linkTypeEnd, to_wit));
from.Save();
MessageBox.Show(string.Format("Work Item {0}, is {1} of Work Item {2}",
from_wit, type.ReverseEnd.Name, to_wit),
"Relation Saved",MessageBoxButton.OK,MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"Cannot Save Work Item Relation",MessageBoxButton.OK,
MessageBoxImage.Error);
}
"TFS/WorkItemTracking/RestClient" calls VSTS Rest API to perform the operations. “ TFS / WorkItemTracking / RestClient”调用VSTS Rest API来执行操作。 You can use the updateWorkItem() method to add a link to the workitem.
您可以使用updateWorkItem()方法将链接添加到工作项。
updateWorkItem()
updateWorkItem()
Syntax
句法
IPromise<Contracts.WorkItem> updateWorkItem(document, id, validateOnly, bypassRules)
Add the required information in "document" and then call the method. 在“文档”中添加所需的信息,然后调用该方法。 Information can be found here: Add a link .
可以在这里找到信息: 添加链接 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.