TFS Work Item Calculated Field Values

I’ve recently been playing with redesigning Work Items in TFS2008, as the Administrator of TFS.

There are certain things you can’t do, such as have a fields value calculated based on the value of one or more other fields (at least not out of the box), but I have come up with a clever way to “get around” this.

I wanted an Importance field to be the value of Priority multiplied by Severity. This couldn’t be done out of the box, and writing custom controls etc., is a little beyond me at the moment. My “solution” was to have the Importance field show Allowed Values based on what Severity (although Priority could be used instead) was set to. So if Severity was set to 3 then Importance could only be multiples of 3 up to 15.

tfs-importance

I also made it that if either Priority or Severity was changed, then Importance would be set back to an empty field. I had to use the Copy rule to set it to an empty value as using Empty, emptied the field but didn’t initially allow you to select a new valid value.

With Importance also being a Required field, when it is cleared, the user has to set a new value! I agree its not perfect, but it kind of works!!

4 Comments

  1. But how did you do that? Can you please write it step by step? The solution is hidden for me in the description above.
    Thanks!

    ReplyDelete
  2. I take it you are familiar with editing work items in TFS? If not, I suggest you search the web to learn a little more and then return here to follow this step-by-step guide.

    1) Open the work item type you want to edit (from server) in Visual Studio.

    2) On the fields tab create a two new field (I called mine MyPriority & MySeverity) of type String:

    MyPriority | String | My.Priority
    MySeverity | String | My.Severity

    3) Do the following for the new fields:

    3a)Right-click the new field and click Open

    3b) On the Rules Tab add SUGGESTEDVALUES and input the values you want to see on the form (mine are in the screen shot!).

    5) If you need to, make them REQUIRED and set a DEFAULT by adding those also. (Default you must type the text to default to... I copied and pasted the 1 value!)

    6) Create another field like so:

    Imporance | Integer | My.Importance

    7) Edit it and for each possible value (i.e. I have 5 (1 to 5)) add a WHEN that matches the exact text that will be shown to user and one of the fields created above (these must all be the same field!).

    For this WHEN condition, set the ALLOWEDVALUES rule (on rule tab) to only allow the values that would be true.

    For Example:

    WHEN
    Field = My.Severity
    Value = 3 (Loss of functionality with a workaround)

    In this example the allowed values are:

    1x3 =3
    2x3=6
    3x3=9
    4x3=12
    5x3=15

    so in my allowed values I add a value for each (i.e. 3,6,9,12,15).

    I hope that makes more sense.

    Unfortunately I don't have enough time to go into it further. Let me know if you have further questions and I will try and help!

    Neil

    ReplyDelete
  3. Thanks for the fast reply! It's a cool workaround but unfortunately it's not my solution. I need a damn "Progress" field. And since is not a built in thing I must create one. I wanted like this:
    1. I create a custom double type field ("Progress").
    2. Set up a formula: let's say completed work / (completed work + remaining work) * 100
    3. Me happy

    Is this thing too complicated for TFS?

    ReplyDelete
  4. I did a quick google for you and found this page:

    http://msdn.microsoft.com/en-us/library/ms194941(VS.80).aspx

    which mentions:

    Microsoft.Scheduling.PercentComplete

    I haven't used it but did a quick add and it didn't error or anything. Just try typing that as the Ref Name in VS.

    Hope this is of some help!

    Neil

    ReplyDelete