vsts-extension-multivalue-c.../xmldetails.md

159 строки
5.4 KiB
Markdown
Исходник Постоянная ссылка Обычный вид История

2016-10-12 00:46:36 +03:00
In TFS, the layout for a work item type is defined via XML. Therefore, you will have to add the Multivalue control to your layout. Here's the series of steps that tell you how to do it.
Learn more about WebLayout XML [here](https://www.visualstudio.com/docs/work/reference/weblayout-xml-elements).
# How to get started
1. Open the `Developer Command Prompt`. Export the XML file to your desktop with the following command.
```
witadmin exportwitd /collection:CollectionURL /p:Project /n:TypeName /f:FileName
```
2. This will create a file in the directory that you specified. Open this file and search for "Work Item Extensions".
2017-03-22 20:40:33 +03:00
```xml
2016-10-12 00:46:36 +03:00
<!--**********************Work Item Extensions**********************
2017-03-22 20:37:29 +03:00
Extension:
Name: vsts-extensions-multivalue-control
Id: ms-devlabs.vsts-extensions-multivalue-control
Control contribution:
Id: ms-devlabs.vsts-extensions-multivalue-control.multivalue-form-control
Description: A work item form control which allows selection of multiple values.
Inputs:
Id: FieldName
Description:
Type: WorkItemField
Field Type: String; PlainText; HTML
Data Type: String
IsRequired: true
Id: Values
Description: Values can be user provided or from suggested values of the backing field
Data Type: String
IsRequired: false
Note: For more information on work item extensions use the following topic:
http://go.microsoft.com/fwlink/?LinkId=816513
-->
2017-03-22 20:39:44 +03:00
```
2016-10-12 00:46:36 +03:00
2017-03-22 20:41:42 +03:00
3. Add an Extension tag to make the control available to the work item form.
2016-10-12 00:46:36 +03:00
2017-03-22 20:40:33 +03:00
```xml
2016-10-12 00:46:36 +03:00
<!--**********************************Work Item Extensions***************************
...
Note: For more information on work item extensions use the following topic:
http://go.microsoft.com/fwlink/?LinkId=816513
-->
<Extensions>
2017-03-22 20:37:29 +03:00
<Extension Id="ms-devlabs.vsts-extensions-multivalue-control" />
2016-10-12 00:46:36 +03:00
</Extensions>
```
You can find your extension ID within the commented blob for "Work Item Extensions":
```XML
<!--**********************************Work Item Extensions***************************
Extension:
2017-03-22 20:37:29 +03:00
Name: vsts-extensions-multivalue-control
Id: ms-devlabs.vsts-extensions-multivalue-control
2016-10-12 00:46:36 +03:00
...
2017-03-22 20:40:33 +03:00
```
2016-10-12 00:46:36 +03:00
2017-03-22 20:41:42 +03:00
4. Add the ControlContribution tag for your Multivalue control. This example adds it to the "Planning" group.
2017-03-22 20:40:33 +03:00
```xml
2016-10-12 00:46:36 +03:00
<Page Id="Details">
...
<Section>
...
<Group Id="Planning">
...
2017-03-22 20:38:18 +03:00
<ControlContribution Label="Label" Id="ms-devlabs.vsts-extensions-multivalue-control.multivalue-form-control">
2016-10-12 00:46:36 +03:00
<Inputs>
<Input Id="FieldName" Value="RefNameOfTheField" />
</Inputs>
</ControlContribution>
<Control Label="Risk" Type="FieldControl" FieldName="Microsoft.VSTS.Common.Risk" />
2017-03-22 20:40:33 +03:00
```
2016-10-12 00:46:36 +03:00
2017-03-22 20:41:42 +03:00
You can find the contribution ID and input information within the commented blob for "Work Item Extensions":
2016-10-12 00:46:36 +03:00
2017-03-22 20:40:33 +03:00
```XML
2016-10-12 00:46:36 +03:00
<!--**********************************Work Item Extensions***************************
...
2017-03-22 20:37:29 +03:00
Control contribution:
Id: ms-devlabs.vsts-extensions-multivalue-control.multivalue-form-control
Description: A work item form control which allows selection of multiple values.
Inputs:
Id: FieldName
Description:
Type: WorkItemField
Field Type: String; PlainText; HTML
Data Type: String
IsRequired: true
Id: Values
Description: Values can be user provided or from suggested values of the backing field
Data Type: String
IsRequired: false
2017-03-22 20:40:33 +03:00
```
2016-10-12 00:46:36 +03:00
For the input tag, the content of the `Id` attribute can be either `FieldName` or `Values`.
If the Id is FieldName, the content of the `Value` attribute should be the name of the field that you want to fill. Suppose you have a field called `MyNamespace.MyField`, the input tag becomes:
```XML
<Input Id="FieldName" Value="MyNamespace.MyField" />
```
2017-10-09 19:27:41 +03:00
To provide a list of value from a global list, you should add `SUGGESTEDVALUES` tag in the field definition.
```XML
<WORKITEMTYPE name="MyWIT">
...
<FIELDS>
...
<FIELD name="MyField" refname="MyNamespace.MyField" type="String">
<SUGGESTEDVALUES expanditems="true">
<GLOBALLIST name="MyGlobalList" />
</SUGGESTEDVALUES>
</FIELD>
```
2017-10-09 21:26:22 +03:00
**NOTE:** This only works if your field type is String. However, if you want to be able to store more than 255 character you should use the PlainText field type. In this case you have two options. First, is to specify the list items individually:
```XML
<WORKITEMTYPE name="MyWIT">
...
<FIELDS>
...
<FIELD name="MyField" refname="MyNamespace.MyField" type="String">
<SUGGESTEDVALUES expanditems="true">
<LISTITEM value="ValueOne" />
<LISTITEM value="ValueTwo" />
</SUGGESTEDVALUES>
</FIELD>
```
Second, is to specify the value inline using the **Values** input:
2017-10-09 19:27:41 +03:00
```XML
<ControlContribution Label="Label" Id="ms-devlabs.vsts-extensions-multivalue-control.multivalue-form-control">
<Inputs>
<Input Id="FieldName" Value="RefNameOfTheField" />
<Input Id="Values" Value="ValueOne;ValueTwo;ValueThree;ValueFour" />
</Inputs>
</ControlContribution>
```
2017-03-22 20:41:42 +03:00
5. Re-import the *.xml* file, using witadmin.
2017-03-22 20:40:33 +03:00
```
2016-10-12 00:46:36 +03:00
witadmin importwitd /collection:CollectionURL /p:Project /f:FileName
2017-03-22 20:40:33 +03:00
```
2016-10-12 00:46:36 +03:00