TFS work item. Allow state transition only if System.AttachedFileCount> 0

Can I do without creating a custom control?

I need to allow the state change of a custom work item only if it contains at least one file. The Attachment Management System.AttachedFileCount field does not support “REQUIRED”: I would like to use it as a condition for the transition.

I am trying to figure this out by adding one custom field that is used only for copying to the value present in System.AttachedCount.
I set the rule "COPY" in a custom field to copy the number of attachments of the work item. Then I can check the value of the custom field in the transition or state using the rule "PROHIBITEDVALUES" = 0. This can be a workaround, but the problem is that it cannot work inside the same state. If I edit the work item without changing the state and add attachments, the value of the custom field will not change.

Are there other rules?

+4
source share
1 answer

Ok, I found a way.

I added a new custom field, an integer type. No rules. In the GUI, I added just above the Attachment Control Fild associated with my new custom field. At the first transition, I set the field with the "EMPTY" rule. In the first state, I added the following rules to the field: - "COPY": a copy from the System.AttachedFileCount field - "QUANTITY": check if the System.AttachedFileCount field has changed, and as a rule I set "EMPTY" - "FORBIDDEN VALUES": set the value to "0", therefore counter = 0 is not allowed (but NULL is allowed!).

when I try to keep workItem in the first state, I throw an error indicating that 0 is a forbidden value, so I need to attach at least one file. IT WORKS !!

L.

+3
source

All Articles