RTC How to add enumeration literal names to a String List using a Script Based Value Set
Select a value from Enumeration 1
Populate a Dependent Enumeration 2, based upon the value selected in Enumeration 1 (using a Dependent Enumeration Value Set for this)
Select a value from Enumeration 2
Based upon the value selected in Enumeration 2, populate a String List
String Lists are populated using either Script Based Value Sets or HTTP Value Sets. What I intend to do is populate the String List from values in another Enumeration (Enum 3) that has no UI presentation of its own.
So, what would the Javascript code look like to do the following:
- Identify the Enumeration 2 value that has been selected in the UI presentation for Enumeration 2
- Push externalValue strings from the appropriate Enum 3 literals into the String List?
Accepted answer
for more examples.
I haven't worked with string lists so far and I am not sure why you would want to use a string list to store enumeration literal id's or display values. For lists of enumeration values RTC provides an enumerationList attribute type for each enumeration.
I am not aware that you can access to the enumeration definition in RTC from the basic JavaScript interface explained in https://jazz.net/wiki/bin/view/Main/AttributeCustomization . For all I know you will have to hardcode all that data somewhere in the script or script configuration.
For that and a host of other reasons, I don't consider the JavaScript attribute customization as a good idea. It is currently way too limited.
You can avoid some of the limitations using Java as explained in https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ . This provides enough common API to access the enumeration definition in the process, I think.
Comments
Ralph,
Thanks for the reply.
The desired end result is to display a multi-select "short list" of the available values from Enumeration 3, based upon a particular value that is selected from Enumeration 2, and to do so as simply as possible. This would be a trivial thing to do if, for example, String Lists could be populated using Dependent Enumeration Value Sets, but String Lists don't support this approach, I have to use a Script Based Value Set. I'll explore using an Enumeration List, instead, to see if I can populate this using a Value Set.
2 other answers
To read the contents of an enum, use the getLabel function (makes no sense, but that is the function you use).
Then, use "push" to load values into your String List.
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_Example
Note that the above sample also shows you another option to pick your "stored values" in the script configuration, rather than using enumerations.
Comments
Hi, Donald,
Thanks for your reply. I'm familiar with the Attribute Customization example. Unfortunately, it is very "hand waving", with no concrete examples, regarding how to deal with Enumerations. I'm hoping that at least one person out in "RTC Land" has successfully created a script based value set that gets an external value from a selected enumeration literal. I'd like to see that code.
I saw the example regarding how to embed stored values within the process configuration source, and I thought that was slick. But, in order to determine which values to pick out of the configuration, I still need to know that external value from the enumeration literal.
I wouldn't need to go through the pain of trying to write this script, if a String List could be populated using a Dependent Enumeration value set. Unfortunately, it can't -- only script based value sets and HTTP value sets can be used, for some reason.