Attribute Customization: Can a Calculated Value use the contents of Checkbox Enumeration List without a save using JS?
In all cases, the necessary dependencies in the Types and Attributes GUI are configured.
This pertains to JavaScript Calculated Values entered into the Attribute Customization GUI.
Is there anyway for a Checkbox Enumeration List Presentation information to be available via a workItem.getValue() function in our scripts?
4 answers
- Created an enumeration called androidVersions, added several, for example, name="KitKat" id="Android 4.4". See discussion here regarding renaming ids. if that interests you.
- Created a custom field for androidVersions as an enumerated checkbox presentation.
- Created a custom string field for androidVersionNumber and made it readonly and dependent on androidVersions attribute.
- Created a script that used workItem.getValue("androidversion"); to retrieve current checked values.
- Concatenated values of the ids from the array returned in previous step. Since there may be multiple values, you get an array of objects returned and you'll need to piece it apart to assign the value.
- Returned string of concatenated values.
dojo.provide("edu.millard.forumtest.ValueProvider");
(function() {
dojo.declare("edu.millard.forumtest.ValueProvider", null, {
getValue: function(attribute, workItem, configuration) {
var selectedValues = workItem.getValue("androidversion");
var valueNames = '';
for (var i=0; i < selectedValues.length; i++) {
valueNames += selectedValues[i].id + " "
}
if (!selectedValues) return "idk";
else return valueNames;
}
});
})();
Comments
I have implemented the same feature in my project area and it is working fine as excepted.
I would suggest you to use a attribute type of Large String will resolve your problem.
Find the script below:
dojo.provide("scripts.defect.targetdatabases");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.string");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("scripts.defect.targetdatabases", null, {
getValue: function(attribute, workItem, configuration) {
var selectedValues = workItem.getValue("TargetDatabases");
var valueNames = '';
for (var i=0; i < selectedValues.length; i++) {
valueNames += selectedValues[i].label + ","
}
if (!selectedValues){
return "";
}
else{
return valueNames.substring(0,valueNames.length-2);
}
}
});
})();
Hi All,
I tried to return a value to “Enumeration List” of “Picker Enumartaion List”, I’m getting below error?
Its working for “Enumeration” of drop down value
Error running operation 'Saving Work Item'
java.lang.ClassCastException: com.ibm.team.workitem.common.model.Identifier incompatible with java.util.Collection
Script :
dojo.provide("edu.millard.forumtest.ValueProvider");
(function() {
dojo.declare("edu.millard.forumtest.ValueProvider", null, {
getValue: function(attribute, workItem, configuration) {
var selectedValues = workItem.getValue("branch3");
var valueNames ="enumBranch.literal.l4";
return valueNames;
}
});
})();
Comments
sam detweiler
Oct 28 '13, 6:55 p.m.Alexander Dawson
Jul 15 '13, 11:42 a.m.Tayane Fernandes
Oct 28 '13, 2:09 p.m.Millard Ellingsworth
FORUM ADMINISTRATOR / JAZZ DEVELOPER Oct 28 '13, 2:13 p.m.sam detweiler
Oct 28 '13, 2:40 p.m.