Making work items forms read-only for a particular state.

Hi,

Does anyone know the simplest way to make work items read-only?

Let's take the bug work item for example. Suppose it has the following states: proposed, approved, ready for incorporation and incorporation complete. When the state moves to "read for incorporation", the bug form for that one record must not be modified.

I endded up setting scoping rules for each field by state. (There must be an easier way!). I did not expect the rules would take into effect immediate once the state field changed. So, if the description field was changed, and then the state set to "ready for incororation", the contents of the description looses its changes. The rules should be applied after record save.

How would I apply scoping rules upon record save? I thought about key off the System.ChangedDate and check it has changed, but once the record is save, the scoping rule will not apply.

Also, is there a way to set the read-only attribute to the LinkControl and AttachmentsControl?

[1041 byte] By [PatrickR] at [2008-2-14]
# 1

There's no other way of making fields r/o when the work item is in a certain state - you have to define READONLY rule for every field you want to make read-only. And the behavior you see is hardcoded - rules get evaluated after each field change.

You cannot make links & attachments read-only.

Thanks,

Alex

# 2

How would I capture the record save event, when all changes have been the commited?

I define a field with the <SERVERDEFAULT... /> and in my state transition, I use <EMPTY /> to clear the field. How do I check if the field is empty? Using <WHEN*...> does not seem to work on empty field.

This is what I mean:

<FIELDS>

<FIELD name="State Change Date" refname="Microsoft.VSTS.Common.StateChangeDate" type="DateTime">
<
HELPTEXT>The date and time of the last change to the state</HELPTEXT>
<
SERVERDEFAULT from="clock"'>
</
FIELD>

</FIELDS>

...

<WORKFLOW>

<STATES>

<STATE value="Ready For Incorporation">

<FIELDS>

....

<FIELD refname="System.Description">
<-- This test condition does not work -->
<
WHENNOT field="Microsoft.VSTS.Common.StateChangeDate" value="">
<
READONLY />
</
WHENNOT>
</
FIELD>

.....

</FIELDS>

</STATE>

</STATES>

<TRANSITIONS>

......

<TRANSITION from="Approved" to="Ready For Incorporation">
<
REASONS>
<
DEFAULTREASON value="Ready for Incorpration" />
</
REASONS>
<
FIELDS>

....

<FIELD refname="Microsoft.VSTS.Common.StateChangeDate">
<
EMPTY />
</FIELD>

.....

</FIELDS>

</TRANSITION>

.....

</TRANSITIONS>

</WORKFLOW>

Thanks.

PatrickR at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 3

V1 workitemtype XML does not support a way to trigger when rules after the item has saved.

I'm assuming that you want the workitem to be permanently readonly. A workaround for your situation might be: When the workitem changes to the state where you want it to be readonly, you can either write a plugin that reacts to workitem change notification events (using the web service) to move it to a readonly node - ie, a node where noone has write access. This will keep all the controls on the form readonly.

Hope that helps.

-Mareen.

MareenPhilip at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 4

Hey Mareen,

That is a very interesting idea. I'll look into it. I have not tried subscribing to event notifications. Would you please recommend any tutorials or blogs on event plug-ins?

I was reading the "Authoring Work Item Types" document, and I got to the discussion on state transition actions. Can this be used to do what you are suggesting? (I have not figured out how actions work yet)

Thanks.

PatrickR at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...

Visual Studio Team System

Site Classified