參考,翻譯此頁面All FIELD XML Elements Reference(http://msdn.microsoft.com/en-us/library/ms194953.aspx)
對於每一個字段的功能,我都親自試驗了一遍,並添加自己對功能的理解和使用用例。
注意:以下功能可以疊加使用,但是不要出現沖突,例如在只讀的情況下要求必填,雖然模板保存驗證上會通過,但實際操作工作項,會導致無法保存。
當打開字段的屬性頁面的時候,你會用到它們。如下圖
Element |
Description and syntax |
|
ALLOWEDVALUES |
Defines a list of values that users can specify in a field list on work item forms and in the query editor. Users must specify one of the values that you list. 定義下拉列表,此列表項為必選項。 例:如上一章組別,我們可以選擇此功能,定義一個必選的組別。它與SUGGESTEDVALUES的區別在於,此功能為必須從列表中選擇一項,SUGGESTEDVALUES則可以不選,或自定義填寫。 更多可參考: Define Pick Lists. |
|
ALLOWEXISTINGVALUE |
Specifies that a field can retain an existing value, even if it is no longer in a pick list. All new field values must be in the list. 類似Textbox錄入框。(無權限定義) 更多可參考: Define Pick Lists. |
|
CANNOTLOSEVALUE |
Specifies that users cannot clear a field of all values after a value has been specified. After the field contains a value, that field must always contain a non-NULL value. 字段一旦填寫保存,則不可再置為空。 如圖,這是在有值保存后,修改為空,提示不能為空。
|
|
COPY |
Copies a specified value to a field when a user creates or modifies a work item. 當用戶創建或修改一個工作項的時候,拷貝一個值到此處。有四個選項。Value-值 | field-字段 | clock-時間 | currentuser-用戶。注意,要對應類型正確,不然無法通過驗證 如圖,選擇的是currentuser,這創建工作項后,直接填寫的是當前操作人員。
例:時間可作為保存當前操作時間。用戶保存當前用戶。值為填入默認值。字段為拷貝字段(注意類型正確,可拷貝某些隱藏屬性值) |
|
DEFAULT |
Specifies a value for a field that is empty when a user creates or modifies a work item. If a field already has a value, the default rule is ignored. 當用戶創建或修改一個工作項的時候,此字段為空,則填入值。如果非空,則忽略操作。有四個選項。Value-值 | field-字段 | clock-時間 | currentuser-用戶。注意,要對應類型正確,不然無法通過驗證。 例:和COPY相同,但只可操作空字段。 |
|
EMPTY |
Clears the field of any value that it contains. The EMPTY rule also makes a field read-only, and you should not be use it with the READONLY rule. The field value is cleared when a user saves the work item, and you cannot specify any value. This rule is primarily used during state transition to clear fields that apply to the state to which the item is transitioning. 清除這個字段的值,且將字段置為只讀。 例:此功能可以用來,當工作流到某個階段的時候,清空此字段值。(我的理解是,但不一定這樣用) |
|
FROZEN |
Specifies that you cannot change the field to a non-empty value after changes are committed. As soon as a user saves the work item with a value in that field, the value can no longer be modified. 字段一旦填寫保存,則不可再修改。 例:類似默認字段中的創建者字段,一旦保存,則不可更改。或需要記錄某些創建時間,也可以使用此功能。 |
|
HELPTEXT |
Defines the text to appear when a user points to the field in the work item form. tooltipText: A string of text that contains between 1 and 255 characters. 此功能未找到!(可能版本問題,目前的幫助信息可以寫在面板的定制里) |
|
MATCH |
Defines a pattern that values of String type fields must match. 定義字段必須匹配的類型,使用"A", "N", and "X"的方式限制字母,數字(純正則表達式使用不成功)。具體見下面的更多參考。 例:可限制此字段輸入的值。如4位數字這樣的要求。 |
|
NOTSAMEAS |
Specifies that a field is not assigned the same value as that to which another specified field is assigned. The value of the field attribute must be a valid reference name of a field. 通過字段名稱,判斷此字段是否和那個字段內容相同,相同則不可保存。 |
|
PROHIBITEDVALUES |
Defines a list of values that a field cannot contain. Users cannot save a work item if the field contains a prohibited value. 定義過濾詞,如出現則不可保存。 例:可作黑名單詞匯過濾功能。 更多可參考: Define Pick Lists. |
|
READONLY |
Specifies that you cannot modify the value to which the field is assigned. 此字段為只讀。
|
|
REQUIRED |
Specifies that users must specify a value for the field. Required fields cannot be empty. Users cannot save a work item until they have assigned values to all required fields. 必填字段,設置后,此字段為必填,不可為空。 例:可將任何字段作為必填項。 |
|
SERVERDEFAULT |
Copies a specified server value to a field when a user saves a work item. These fields usually appear as read-only on the form. 復制一個服務器值到此字段(clock-時間 | currentuser-用戶),這個字段被默認為只讀(為其再添加只讀屬性會有問題)。 |
|
SUGGESTEDVALUES |
Defines a suggested list of values that users can specify in a field list on work item forms and in the query editor. Users can specify values other than those that you suggest. 定義下拉列表,此列表可選,或自定義填寫。與ALLOWEDVALUES的區別是,ALLOWEDVALUES必須選擇列表項填寫,而SUGGESTEDVALUES是可以不填,或填寫自定義內容的。 例:可作為建議選擇項,建議一些內容。比如我們可以修改"標題"的字段,為其加入一些建議選擇項,方便填寫。 更多可參考: Define Pick Lists. |
|
VALIDUSER |
Restricts work items from being modified by users who belong to the group that you specify. The default group is the Team Foundation Valid Users group. All attributes are optional. All attributes must consist of a string of text that contains between 1 and 255 characters. You can use tokens to specify groups. For more information, see Use Tokens to Reference Users and Groups. 不知為何,我這里只能選collection的全劇組,無法添加[project]組。因此我這里實驗暫時不成功。 |
|
WHEN |
Specifies one or more rules to apply to the current field when another field has a specific value. The parent FIELD element defines the current field. 當某一個字段為某一個狀態值的時候,此字段可以做某些事情。可做的事情包括<ALLOWEDVALUES>、<ALLOWEXISTINGVALUE>、<CANNOTLOSEVALUE>、<COPY> 、<DEFAULT>、<EMPTY>、<FROZEN>、<MATCH>、<NOTSAMEAS>、<PROHIBITEDVALUES>、<READONLY>、<REQUIRED>、<SERVERDEFAULT>、<SUGGESTEDVALUES>、<VALIDUSER> 例:如我們上章添加了組別,則可以設置當選擇"組2"的時候,此字段出現下拉選項,可選擇"組2一小隊"或"組2二小隊" |
|
WHENNOT |
Specifies one or more rules to apply to the current field when another field does not have a specific value. The parent FIELD element defines the current field. 當某一個字段為非某一個狀態值的時候,此字段可做某些事情。可做的事情包括<ALLOWEDVALUES>、<ALLOWEXISTINGVALUE>、<CANNOTLOSEVALUE>、<COPY> 、<DEFAULT>、<EMPTY>、<FROZEN>、<MATCH>、<NOTSAMEAS>、<PROHIBITEDVALUES>、<READONLY>、<REQUIRED>、<SERVERDEFAULT>、<SUGGESTEDVALUES>、<VALIDUSER> 例:我們上章添加了組別,則可以設置任何時候,我們都可選擇"一小隊"、"二小隊",除了當選擇"組2"的時候。 |
|
WHENCHANGED |
Specifies one or more rules to apply to the current field when another field is changed during the revision of the work item. The parent FIELD element defines the current field. 當某一個字段狀態改變的時候,此字段可以做某些事情。可做的事情包括<ALLOWEDVALUES>、<ALLOWEXISTINGVALUE>、<CANNOTLOSEVALUE>、<COPY> 、<DEFAULT>、<EMPTY>、<FROZEN>、<MATCH>、<NOTSAMEAS>、<PROHIBITEDVALUES>、<READONLY>、<REQUIRED>、<SERVERDEFAULT>、<SUGGESTEDVALUES>、<VALIDUSER> |
|
WHENNOTCHANGED |
Specifies one or more rules to apply to the current field when another field is not changed during the revision of the work item. The parent element defines the current field. 當某一個字段狀態未改變的時候,此字段可以做某些事情。可做的事情包括<ALLOWEDVALUES>、<ALLOWEXISTINGVALUE>、<CANNOTLOSEVALUE>、<COPY> 、<DEFAULT>、<EMPTY>、<FROZEN>、<MATCH>、<NOTSAMEAS>、<PROHIBITEDVALUES>、<READONLY>、<REQUIRED>、<SERVERDEFAULT>、<SUGGESTEDVALUES>、<VALIDUSER> |