1

I would like to know how to verify that a newly created work item was assigned a child work item.

Some background info -C# TFS Plugin -If a work item is created, check to see if existing work item is linked, if not, create one.

I thought there may be a workitem field that is populated that could be checked for null. Unfortunately, after hours of research on the Extending TFS portion of MSDN, it doesn't look as if there is such field. More like multiple linked fields. Needless to say I am very new to TFS API and any help would be great.

blkhdy
  • 33
  • 6
  • I think this is what you are looking for: http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.workitemtracking.client.workitem.workitemlinks.aspx I guess you already have the WorkItem object available. – MikeR Sep 10 '13 at 15:08
  • I think you got this one MikeR, I have yet to test it out but this looks as if it is pointing to a varible that stores what type of link if any. From there I could probably just check if null. – blkhdy Sep 10 '13 at 20:57
  • if (workItemOriginal.WorkItemLinks == null ) – blkhdy Sep 10 '13 at 21:03

1 Answers1

0

You could write a web-service and then subscribe it to TFS Event Service, so you'll receive notifications and then you can access the TFS API in order to check you condition and even make changes.

Reference:

In order to get the Work Item details, you need to parse the XML, get the Work Item ID and then, use the TFS API, like below:

TeamFoundationServer tfsServer = new TeamFoundationServer("http://tfsServer:8080");
WorkItemStore store = new WorkItemStore(tfsServer);
WorkItem wi = store.GetWorkItem(workItemID);

For details in how look for the likend workItems, take a look in this question: Retrieving work items and their linked work items in a single query using the TFS APIs

Community
  • 1
  • 1
Oberdan Nunes
  • 509
  • 4
  • 13
  • I have the web service built for the most part. Right now the service runs each time a specific type of work item is created, however, the real question is... **how to check if it has a child work item set by the user creating the new work item.** – blkhdy Sep 10 '13 at 12:20
  • You need to use parse the XML, get the WI ID, and then, use the TFS API to get the details. I can't test the code right now, but I'll edit the answer and put some code there. – Oberdan Nunes Sep 10 '13 at 17:27
  • Currently, I am able to get the details of the newly created work item. I needed to know what to drill down to as far as a feild I can check to see if the user linked an existing work item. – blkhdy Sep 10 '13 at 20:55