You can use a script to set the values of a value set. The script can .use values of
other attributes or independent data attributes, such as time, to set the values of the value set.
About this task
This task uses the Script Based Value Set provider to provide values for a
string (Small String, Medium String, Large String) or String List type attribute. If a script-based
value set depends on other attributes, the script uses the values of the attributes from the last
time the work item was saved. The one exception to this is in the Eclipse client when one of the
attributes is a String List type, in which case the script is not executed until the user selects a
value for that attribute.
Procedure
-
Open the Attribute Customization page:
-
In the Team Artifacts view of the Work Items perspective, right-click the project area and
select Open.
-
Click the Process Configuration tab.
-
Expand , and then click Attribute Customization.
-
Select Value Sets, then click Add. Enter a name
that describes the customization. Select Script Based Value Set from the
Provider drop-down list. Click OK.
-
Enter the script in the Script field. Alternatively, click Load to
select a file that contains the script code.
For example, the following is a very simple value set
script:
dojo.provide("com.example.StringValueSetProvider");
(function() {
dojo.declare("com.example.StringValueSetProvider", null, {
getValueSet: function(attributeId, workItem, configuration) {
return ["this", "value", "set", "is", "coming", "from", "a", "script", "!!!"];
}
});
})();
Note: The Configuration section of the user interface lets you select the
Filtered checkbox to filter the values in the value set. If you select
Filtered, specify the getFilteredValueSet method, rather than the getValueSet
method in the script.
-
Click Attributes and Types. Select the work item type, such as Defect or
Task. Scroll to the Attributes section. Click Add.
Create a custom attribute for the value set. In the Type field, select a string (Small String,
Medium String, Large String) or String List type. In the Value Set field, select the Script Based
Value Set that you previously created. Click OK to save the new
attribute.
-
Click Editor Presentations. Select the editor presentation to which you
want to add the field for the new attribute. Select the tab and then section to which you want to
add the field. For example, the Details section on the
Overview tab. With the section selected, click Add
Presentation to add a field for the new attribute.
-
Click Save to save your changes to the project area.