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; } }); })();
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
|
Accepted answer
This is basically a JavaScript question. You should use the split function to divide "target_types" into multiple values.
http://www.w3schools.com/jsref/jsref_split.asp Orna Hitron selected this answer as the correct answer
Comments
Orna Hitron
commented Nov 22 '16, 2:30 a.m.
Thanks for the suggested resolution,
I used the split function: target_types.split("|");
and the RTC Condition script works properly.
Thanks!!!
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.