Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes


Accepted answer

Permanent link
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

0 votes

Comments

Thanks for the suggested resolution,

 I used the split function: target_types.split("|"); 
and the RTC Condition script works properly.
Thanks!!!


Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941

Question asked: Nov 21 '16, 2:56 p.m.

Question was seen: 1,538 times

Last updated: Nov 22 '16, 2:30 a.m.

Confirmation Cancel Confirm