This project is read-only.
3

Closed

Parent state depends on different children

description

Is it possible to change the state of a work item, depending on the state of all the children (when they are of different types)?If yes, give a couple of examples, please.
Closed Feb 14, 2015 at 4:06 PM by giuliov
Moved to GitHub Issue #6

comments

stimanov wrote Nov 1, 2013 at 2:09 PM

The same problem here. Tests show that directly it is impossible.
But I have an idea about workaround which may help. Unfortunately this workaround requires modification of the process. It is needed to add fields to the parent work item type for each child WIT type to which children statuses will be aggregated. Final aggregation will be done in 2 steps:
  1. Aggregation of children statuses to the corresponding fields of the parent WIT.
  2. Aggregation of these fields inside the parent WIT to the status of this WIT.
I didn't check this yet but imho it should work.

wrote Nov 1, 2013 at 2:48 PM

stimanov wrote Nov 7, 2013 at 12:06 PM

I have checked workaround mentioned above. In works.

molodec5 wrote Feb 28, 2014 at 12:44 PM

It's easy:

Modifications below allows you two things:
a) multiple WI types in triggers
b) WIs of different types in common rule (your question)

Only 3 steps you need to do:
  1. ConfigAggregatorItem.cs
    public string[] WorkItemTypes { get; set; }  // <-- instead of "WorkItemType"
    public string WITsOperator { get; set; } // new property 
    
  2. TFSAggregatorSettings.cs
    Instead: 
    aggItem.WorkItemType = xmlAggItem.Attribute("workItemType").Value;
    
    Write:
    aggItem.WorkItemTypes = xmlAggItem.Attribute("workItemType").Value.Split(';');
    aggItem.WITsOperator = xmlAggItem.LoadAttribute("WITsOperator", "Or");
    
  3. WorkItemChangedEventHandler.cs
    Replace:
// remove the kids that are not the right type that we are working with
ConfigAggregatorItem configAggregatorItemClosure = configAggregatorItem;
iterateFromParents.RemoveAll(x => x.Type.Name != configAggregatorItemClosure.WorkItemType);
To:
// remove the kids that are not the right type that we are working with
if (configAggregatorItem.WITsOperator == "Or")
    iterateFromParents.RemoveAll(x => x.Type.Name != eventWorkItem.Type.Name);
else
    iterateFromParents.RemoveAll(x => !(configAggregatorItem.WorkItemTypes.Contains(x.Type.Name)));
Now you can config your XML file with multiple types in rules and (if you want) make rule common by adding WITsOperator="And":
<AggregatorItem operationType="String" linkType="Parent" linkLevel="1" workItemType="type1;type2" WITsOperator="And">
...
</AggregatorItem>

wrote Feb 14, 2015 at 4:06 PM