none
Adding field to a requirement work item that gets its value from a child item

    Question

  • I am using 2 Req WITs, one of type feature, the 2nd of type scenario which is a child of the 1st one. I would like to add a field to the parent, lets say "MyField", not updatable manually but updated from either an exisiting field or a new integer field I add to 2nd one. So if I have 2 children with a value in this new field of 5, the 2nd with 10, then in the parent item I would like to have 15 in the "MyField".

    Is it feasible? if yes, any pointer to any doc or reference

    Thanks in advance.

    Wednesday, March 28, 2012 8:21 PM

Answers

  • Hi eliassal,


    this is a very common scenario that most people working with the process template are faced with and there are various approaches to solve this:


    1. You can create a custom control that will get the links to the child objects, read the values of the childs and write the result into the parent. However, this will not work for Web Access or when editing the WorkItems through Excel or any other client... Another limitation would be that only when you open the parent item the values would be updated, but not when you change the values within the childs (unless you create a custom control there too, which will update the parent, etc...)


    2. The most common way to solve this problem is to implement a server-side plug-in. On codeplex, there is an implementation of a plug-in called "TFS Aggregator" which can do exactly what you ask for. Have a look:

    http://tfsaggregator.codeplex.com/


    3. An alternative is to do this as a service which registers to the WorkItemChanged event. See this example which describes a solution for your scenario (summing up values from child WorkItems):

    http://www.ewaldhofman.nl/?tag=/TFS+2010+API%3B+Event+service

    Advantage of this solution is that it does not run within the application pool of the TFS and hence, does not pose a risk to the connectivity of your Team Foundation Server the way a server-side plug-in can do.

    => Common to all the described approaches is that when you miss one change event (e.g. the plugin crashed and TFS kicked it out of the pool), your data will be inconsistent until you trigger an update for that workitem again. To overcome this limitation, you can for example create a scheduled task that runs a consistency check every day and updates WorkItems if there values are not in sync anymore because of a missed event. This can easily be done through the WorkItem-API of TFS

    Hope this info helps...

    Best regards,

    Riccardo


    Sunday, April 01, 2012 5:50 AM

All replies

  • You can see the following thread here:

    http://social.msdn.microsoft.com/Forums/en-US/tfsworkitemtracking/thread/4806bdc9-6e95-4c4e-b349-e8b296b68358

    You can also see this video on Process Customization:

    http://mohamedradwan.wordpress.com/2011/10/06/customize-tfs-process-2010-video/


    We are volunteers, if the reply help you mark it as your answer. thanks!!

    Blog: http://mohamedradwan.wordpress.com

     

    Wednesday, March 28, 2012 9:02 PM
  • Hi Eliassal, 

    Thanks for your post.

    As far as I know, there’s no such a default work item Rule support to copy value from other work items. To get field value from another work item, you should create the custom work item control to achieve that. Please refer to: http://witcustomcontrols.codeplex.com/releases/view/7240.     


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, March 29, 2012 6:49 AM
    Moderator
  • Hi eliassal,


    this is a very common scenario that most people working with the process template are faced with and there are various approaches to solve this:


    1. You can create a custom control that will get the links to the child objects, read the values of the childs and write the result into the parent. However, this will not work for Web Access or when editing the WorkItems through Excel or any other client... Another limitation would be that only when you open the parent item the values would be updated, but not when you change the values within the childs (unless you create a custom control there too, which will update the parent, etc...)


    2. The most common way to solve this problem is to implement a server-side plug-in. On codeplex, there is an implementation of a plug-in called "TFS Aggregator" which can do exactly what you ask for. Have a look:

    http://tfsaggregator.codeplex.com/


    3. An alternative is to do this as a service which registers to the WorkItemChanged event. See this example which describes a solution for your scenario (summing up values from child WorkItems):

    http://www.ewaldhofman.nl/?tag=/TFS+2010+API%3B+Event+service

    Advantage of this solution is that it does not run within the application pool of the TFS and hence, does not pose a risk to the connectivity of your Team Foundation Server the way a server-side plug-in can do.

    => Common to all the described approaches is that when you miss one change event (e.g. the plugin crashed and TFS kicked it out of the pool), your data will be inconsistent until you trigger an update for that workitem again. To overcome this limitation, you can for example create a scheduled task that runs a consistency check every day and updates WorkItems if there values are not in sync anymore because of a missed event. This can easily be done through the WorkItem-API of TFS

    Hope this info helps...

    Best regards,

    Riccardo


    Sunday, April 01, 2012 5:50 AM