Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS Work Item - Allow transition to state only if System.AttachedFileCount > 0

Is it possible to do without having to create a custom control?

I need to allow the change of state of a custom work item only if it has at least one file attached. System.AttachedFileCount field of Attachments Control doesn't support "REQUIRED": I would like to use it as a condition for a transition.

I am trying to figure it out by adding one custom Field used only to copy in the value present in System.AttachedCount.
I set the rule "COPY" in the custom field in order to copy in 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 could 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 some attachments, the value of the custom field does not change.

Are there is some other rules to try?

like image 986
zero51 Avatar asked Oct 23 '22 12:10

zero51


1 Answers

Ok, I found a way.

I added a new custom field, integer type. No rules. On the GUI, I added just above the Attachment Control a Fild control referenced to my new custom field. At a first transition, I set the field with rule "EMPTY". At a first state, I added to the field the following rules: - "COPY": copy from field System.AttachedFileCount - "WHENCHANGED": check if the field System.AttachedFileCount changes and as rule I set "EMPTY" - "PROHIBITEDVALUES": set che value "0", so counter = 0 is not allowed (but EMPTY is Allowed!).

when I try to save the workItem at the first state i gives the error indicating that 0 is a prohibited value, so I need to attach at least one file.. IT WORKS!!

L.

like image 135
zero51 Avatar answered Nov 04 '22 18:11

zero51