Work Item rules workaround: Deactivating a work item type

My colleague, Gregg, and I have been posting a series of workarounds to achieve scenarios in Work Item Tracking that aren’t straightforward using our rule engine. In the last post in this series, Gregg blogged about forcing selection of reason. Let’s take a look at another question that we often get: “How do I deactivate/retire a work item type? I don’t want to destroy the type because I want to report on it, but I don’t want others to create new work items of this type”.

Using a similar approach to the previous workarounds:

  1. Create a DeactivatedType field as part of the type you want to deactivate
  2. Add the following rules to the field:

<FieldDefinition type="String" name="Deactivated Type" refname="Demo.DeactivatedType">

  <COPY from="value" value="This work item type has been deactivated. Use Bug type instead." />

  <PROHIBITEDVALUES>
    <LISTITEM value="This work item type has been deactivated. Use Bug type instead." />
  </PROHIBITEDVALUES>

</FieldDefinition>

 

Now, add this field to the form definition. Make it prominent, let’s put it at the top of the form. Here’s how the form would look like when a user tries to create a work item of this type:

image

 

This workaround works by copying a value to our new field that violates the prohibited values rule, so the new work item cannot be saved. This achieves the net result that your type hasn’t been deleted but work items of this type cannot be created.

Comments