It's all about the answers!

Ask a question

How to find in a script existence of a specific value from enumeration list attribute

Orna Hitron (32) | asked Nov 21 '16, 2:56 p.m.
 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:

(function() {
    var 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;
        return false;

console.log("Types: '" + target_types + "'") output is correct -> the searched literal is listed in the log:
          !ENTRY 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

permanent link
Donald Nong (14.5k414) | answered Nov 21 '16, 6:00 p.m.
This is basically a JavaScript question. You should use the split function to divide "target_types" into multiple values.
Orna Hitron selected this answer as the correct answer

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.

Your answer

Register or to post your answer.