Edwin Castro

I have two related questions. We want to make the work item UI non-interactive for certain fields after the work item has transitioned to the Closed state. Is this possible

Secondly, we want to keep some fields editable and we would like to be able to save modifications to those fields while the work item is in the Closed state. Currently we can modify data but we can't save while in the Closed state. We need to change the state to something else and then close the work item again. Is there a way to save data modification after a work item as been saved as Closed How does VS know that a work item is "Closed" and modifications to a field can't be saved unless the item is transitioned to a different state


Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Vic Tang - MSFT

<READONLY> rule is the answer to your first question. An example as below makes Rank field readonly while the workitem state is Closed.

<WORKFLOW>

<STATES>

<STATE value="Closed">

<FIELDS>

<FIELD refname="Microsoft.VSTS.Common.Rank">

<READONLY />

</FIELD>

Hope it helps,

Vic





Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Vic Tang - MSFT

To answer your second question - you sure can accomplish that. I guess there are some rules specified under <WORKFLOW> \ <STATES> \ <STATE value="Closed"> \ <FIELDS>, which prevent you from saving the modification. can you post the xml





Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Aliaksei Baturytski - MSFT

Answering your second question... Most likely your work item type definition has some rules that prohibits updates to the work item. TFS itself does not have any special logic for any state. Please review your work item type definition for rules.

Thanks,

Alex





Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Edwin Castro

I have reviewed my rules and I can't find any restrictions in our xml files. Here is an example from one:

<STATE value="Closed">
<FIELDS>
<FIELD refname="System.ChangedBy">
<SERVERDEFAULT from="currentuser" />
</FIELD>
<FIELD refname="Microsoft.VSTS.Common.ClosedBy">
<SERVERDEFAULT from="currentuser" />
</FIELD>
<FIELD refname="Microsoft.VSTS.Common.ClosedDate">
<SERVERDEFAULT from="clock" />
</FIELD>
</FIELDS>
</STATE>

I also reviewed rules in transitions and found nothing to explain the behavior I described in the second question.




Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Vic Tang - MSFT

Are you trying to modify the value in "Changed by, Closed date and Closed date" fields while the state is Closed

SERVERDEFAULT rule prevents you from saving your modifications. This rule is explained on MSDN as below.

Unlike <DEFAULT> and <COPY> that fill in values at the start of editing, the <SERVERDEFAULT> rule fills in a value when the work item is committed to the database. This occurs at save time, and the user cannot override the value. Such fields appear read-only on the form. This rule is used for fields such as "Last Changed By" and "Last Changed On" to support secure audit trails. This element accepts for and not attributes. For more information, see SERVERDEFAULT Element (Work Item Type Definition Schema).

Hope this helps,
Vic




Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Edwin Castro

I still do not understand why <SERVERDEFAULT> affects me when I change other values... Clearly I'm not changing those fields because they are indeed read-only on the form as the docs say. It also makes sense that they would get updated at save time. So why can't I save my item if it is already in the Closed state and I change other fields




Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Vic Tang - MSFT

Can you post the completed workitem type xml file Also, specify which fields you are changing I will try to repro your issue.

And what is the error message, if there are any, when you attempt to save the changes





Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Edwin Castro

I can't post the actual content of our xml files. I'll work on a repro and post that soonish...




Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Edwin Castro

In trying to repro the issue I compared a WIT that has the behavior I described and one that didn't. The difference was that the <SERVERDEFAULT> rules existed in the transition to Closed in the WIT that worked fine. In the WIT that doesn't work quite well the <SERVERDEFAULT> rules exist in the Closed state itself.

Now I understand. Once a field is set with <SERVERDEFAULT> it can't be updated while the work item is in that state so when I tried to save a second time the rule would run and try to update the field but I didn't have permission to update the field because it had been set previously.

Thank you all for your help!




Re: Team Foundation Server - Work Item Tracking Changing Fields in Work Items after they have been Closed

Vic Tang - MSFT

You're welcome. :-)