Work Item Rules Workarounds: Validating Area Path

There are many times when we get asked how to implement seemingly basic scenarios with the work item rules engine. What we’d like to do is publish a set of  blog posts with way to implement these commonly requested scenarios.

One of those questions is: “How can I validate Area Path”. For example:


In the above example, the company doesn’t want people to be able to select the root node of Area Path, nor the second level. Is there a way to force selection at a certain level, or to restrict selection at upper levels?

So we came up with a “workaround” of sorts. A way to make this work.  Here are the steps:

  1. Create a AreaPathValidation field
  2. Create a Form tab called “Validation Errors” and place AreaPathValidation on it
  3. Find out the AreaIDs of the restricted area paths
  4. Attached the following rules to AreaPathValidation field:

<FieldDefinition type="String" name="Area Path Validation" refname="Demo.AreaPathValidation">


    <LISTITEM value="Area path has to be at least 3 levels deep" />


  <COPY from="value" value="No Errors" />

  <WHEN field="System.AreaId" value="68">

    <COPY from="value" value="Area path has to be at least 3 levels deep" />


  <WHEN field="System.AreaId" value="105">

    <COPY from="value" value="Area path has to be at least 3 levels deep" />


  <WHEN field="System.AreaId" value="108">

    <COPY from="value" value="Area path has to be at least 3 levels deep" />




In the above set of rules:

  • The AreaPathValidation field acts as an error field. It either contains “No errors”, which means all is well, or some error message
  • The PROHIBITEDVALUES make the error message being copied into it an invalid state. The work item cannot be saved with that error message copied in.
  • The initial COPY command, initializes the field to “No errors”
  • the WHEN commands copy in the error message if the Area  Path is any of the three nodes we want to restrict.

Why are we using System.AreaId instead of System.AreaPath? -- Because you are not able to use System.AreaPath in a WHEN clause.

How do we find out System.AreaId? – You take a work item (without the rules above), set it to an Area Path that you want to find out the AreaID on. Save it. Then look in the “History” field, where we list all the changed values. AreaId will be listed as one of the changed values (for some reason), and you can find the AreaID out that way.

The next step is to place it on a form. We choose to make it look something like this:


Note how our new Area Path Validation field really becomes a way to display an intelligent error message to the user. Our work item form notes that a rule violation has appeared on the “Validation Errors” tab and places in yellow icon on it. Kind of handy.

A natural question is: “Why don’t we use the Area Path security for this?” The answer is, If you deny access to a top-level node in the Area Path, the area path security assumes a lower nodes inherit those permissions. So denying the top node also denies lower nodes and doesn’t solve our problem.

Well, that was our first “Work Item Rule Workaround” post. We have a few more to post. If you have ideas for scenarios you’d love to implement, or scenarios that you have implemented in some creative way, please let us know, and we’ll post about them.

Comments (8)

  1. Jason Barile on Make Sure You Reinstall VS 2008 SP1 after Installing Team Explorer Charles Sterling on

  2. JaapM says:

    Nice workaround, but seems not to work in TSWA. When changing the AreaPath to a valid value, the validationfield is not refreshed, so it remains in invalid state. In Team Explorer it’s working fine.

    Any solutions for this?


  3. In our last post in this series, Gregg blogged about validating area path . Let’s take a look at another

  4. navteam says:

    The community content on the VS2005 Help Topic for this issue ( gives this workaround for the TSWA issue:

    <WHENCHANGED field="System.IterationPath">

    <COPY from="value" value="" />


    I haven’t tried it out, though.

  5. TJ says:

    Worked first time in TFS 2010.  For those of you having issues, the xml to copy paste should actually be <FIELD… />  not <FieldDefinition… />   I also wanted to show 3 different error messages depending on the AreaID, so I had to include 3 different <LISTITEM…/> elements in the PROHIBITEDVALUES section.    For the form layout (which is weird and painful even in the 2010 Process Editor), Just add a new TabPage, then add a New Control to the TabPage, then set the FieldName property on the right.  It's a dropbox that will poplate w/ all the new validation control was at the top  (so will yours if you copy/paste demo verbatim cuz it'll be Demo.AreaPathValidation that shows up first).  Again – just awesome!

  6. Webb Deneys says:

    That works if you have very few areas and they are not volatile – any way short of coding something to work around that (in my case I need to enforce certain rules when an area is 'under' a particular root which is looking much harder than I was anticipating).

  7. Dave Potts says:

    You can adapt the approach to other uses.  E.g. forcing a field to be changed on a state transition:…/tfs-2010-transition-validation-to-force-field-change

Skip to main content