How to find in a script existence of a specific value from enumeration list attribute
Attribute "target-type-list" is a list based on enumeration that includes :
target-type.literal.l11 , target-type.literal.l8 and a few more literals.
I need to find out if one of the 'existing' values is id "target-type.literal.l11" (this literal name is "Other") .
What is the way to "search" for a specific value in a list attribute?
Current (not working :-( ) script:
/*******************************************************************************/
dojo.provide("com.MTD_OtherTargetType");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.MTD_OtherTargetType", null, {
matches: function(workItem, configuration) {
var target_types = workItem.getValue("target-type-list");
var isother = "No";
console.log("Types: '" + target_types + "'");
for (var i=0; i < target_types.length; i++) {
console.log("Type: '" + target_types[i] + "'");
if ( target_types[i] === "target-type.literal.l11" )
isother = "Yes";
}
if ( isother === "Yes" )
return true;
else
return false;
}
});
})();
dojo.provide("com.MTD_OtherTargetType");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.MTD_OtherTargetType", null, {
matches: function(workItem, configuration) {
var target_types = workItem.getValue("target-type-list");
var isother = "No";
console.log("Types: '" + target_types + "'");
for (var i=0; i < target_types.length; i++) {
console.log("Type: '" + target_types[i] + "'");
if ( target_types[i] === "target-type.literal.l11" )
isother = "Yes";
}
if ( isother === "Yes" )
return true;
else
return false;
}
});
})();
console.log("Types: '" + target_types + "'") output is correct -> the searched literal is listed in the log:
!ENTRY com.ibm.team.rtc.common.scriptengine 1 0 2016-11-21 21:13:32.799
!MESSAGE LOG: 'Types: '|target-type.literal.l11|target-type.literal.l8|''
But the log print inside the 'for' loop shows that var i is looping letter by letter in the var 'target_types' ,
How to loop by values (by literals inside target_types) ?
Thanks, Orna