It's all about the answers!

Ask a question

How to read string to text field from enumaration using calculated value in RTC


Prasad Makkena (1716) | asked Jan 10 '18, 12:32 p.m.

Hi Team,

RTC version 6.0.2 and using calculated Value.

I want to read string to small string field from enumeration based on user selection.

For example, if I selected value in enumeration as [aaaaaaa bbbbbbbb ccccccccc] and I should only read  "aaaaaaa"  from enumeration to small string field. I was able to read entire value([aaaaaaa bbbbbbbb ccccccccc]) using getLabel() but I am unable to read string position. Something wrong with my code, can you please help here.

Here is my code.

dojo.provide("com.example.programid");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {

 var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
 dojo.declare("com.example.programid",null, {
    getValue: function(attribute, workItem, configuration) {

   var ppmoprj;

            ppmoprj = workItem.getLabel("com.attribute.ppmoprj");
            var partialStr = ppmoprj.substring(2, ppmoprj.indexOf("]"));
            var res = partialStr.substring(0, partialStr.indexOf(" "));
            //var res = ppmoprj;
   return res;
    }
    });
})();      

2 answers



permanent link
Donald Nong (14.5k614) | answered Jan 10 '18, 9:40 p.m.

I'm not sure why you would get a list instead of a plain string when reading the label of an Enumeration attribute. Are you really sure it's Enumeration, not Enumeration List?

If you are only asking how to process the string as is, you'd better use the split() function.
https://www.w3schools.com/jsref/jsref_split.asp


permanent link
Ralph Schoon (63.4k33646) | answered Jan 11 '18, 7:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I think one can learn a lot from this post and the duplicate posts that I think I have seen before.

  1. It is likely an enumerationList attribute type and not an enumertion. e.g. for an enumeration MyEnumeration the type shows in the admin UI MyEnumeration List and not MyEnumeration
  2. Someone who wants to do attribute customization should be aware what they are working against, understand there is a difference and express it in a question
  3. From the documentation https://jazz.net/wiki/bin/view/Main/AttributeCustomization list types (of any type) are not listed as supported in the attribute customization API. there is a list of supported types - enumeration and string/primitive but no lists are mentioned; I can not find out how to retrieve the value as a list; In Java you really get a list with the selected entries; I am not sure how to get it here
  4. Try to look at JavaScript specific sites if you struggle with that.
  5. I would also say know RTC Process Customization – What you can and cannot do 

Your answer


Register or 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.