It's all about the answers!

Ask a question

RTC How to add enumeration literal names to a String List using a Script Based Value Set


Todd Dunnavant (47713) | asked Apr 21 '16, 11:30 a.m.
My client is implementing an RTC configuration that includes the following:

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


permanent link
Ralph Schoon (56.2k23642) | answered Apr 22 '16, 3:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Apr 22 '16, 3:31 a.m.
See
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.
Todd Dunnavant selected this answer as the correct answer

Comments
Todd Dunnavant commented Apr 22 '16, 9:24 a.m.

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



permanent link
Todd Dunnavant (47713) | answered Apr 25 '16, 4:05 p.m.
edited Apr 25 '16, 4:06 p.m.
Here is what I discovered:

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.

Comments
Ralph Schoon commented Apr 26 '16, 1:50 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

This means the set function looks at the display value rather than the ID to find the enumeration literal.


permanent link
Donald Nong (14.4k213) | answered Apr 22 '16, 2:03 a.m.
When you get to the place to write your own code, just click on "Fill in example" and you should have the very basic code skeleton. For a more detailed example, see the wiki below.
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
Todd Dunnavant commented Apr 22 '16, 2:52 a.m. | edited Apr 22 '16, 2:53 a.m.

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.

Your answer


Register or to post your answer.