Divide two fields in TFS 2012

Feb 17, 2014 at 1:38 PM
Edited Feb 17, 2014 at 1:40 PM
I'm having trouble dividing two fields in TFS 2012. This is my xml:
<AggregatorItems tfsServerUrl="http://tfspath/tfs/DefaultCollection" loggingVerbosity="Diagnostic">
  
  <!--Divide Business value with effort and put in Bussiness value per effort field-->
  <AggregatorItem operationType="Numeric" operation="Divide" linkType="Self" workItemType="Product Backlog Item">
 <SourceItem name="Business Value"/>
<SourceItem name="Effort"/>      
        <TargetItem name="Business Value per Effort"/>
  </AggregatorItem>
</AggregatorItems>
What happens is that if Effort is 4 and Business Value is 10.000, Business Value per Effort gets set to 4. Any thoughts?

Edit: Effort is a double while Business Value is an integer. This does not seem like something I can change, so the best option would be to get TFS Aggregator to accept an integer.
Aug 29, 2014 at 4:57 PM
This is caused by a bug in the WorkItemHelper.cs file. The reason it fails is that Business Value is an Integer, and Effort is a Double. These can normally be cast without any issues, but in WorkItemHelper, it is using generics, and these are a bit more picky - in a nushell, you cannot cast a boxed int32 to a Double from within a generic. The fix is to change the following in line 41 of WorkItemHelper.cs:
            TType convertedValue = (TType) workItem[fieldName];
            return convertedValue;
To:
            object obj = workItem[fieldName];

            TypeConverter converter = TypeDescriptor.GetConverter(obj);
            if (converter.CanConvertTo(typeof(TType)))
            {
                var result = converter.ConvertTo(obj, typeof(TType));
                return (TType)result;
            }
Recompile it and deploy.