It's all about the answers!

Ask a question

RTC Script - How to do a calculted Script using enumerations


Matt Muller (59813574) | asked Jun 18 '15, 6:08 a.m.
edited Jun 18 '15, 7:04 a.m. by Ralph Schoon (63.1k33646)

Good morning all,

I'm new to Java script but I have done some basic standard script stuff.  I've seen the labs etc, but I never have time to investigate these or seem to have the time to invest in Java script...  so any help tips etc would be great.

I have an Enumeration Setup:

Impact:   None / Low / Medium / High  (using Literals com.ibm.ImpactLiteral1 - com.ibm.ImpactLiteral4 (for example)

The Values I want to use within the Script are as follows: None = 0 / Low = 3 / Medium = 6 / High = 9.

I have then setup two attributes mapped to the new Enumeration:

Names and ID's are:

Impact1 =  com.ibm.Impact_cost

Impact2 =  com.ibm.Impact_time

I want to create a script that adds up the Enumeration values for Impact1 and Impact2

ImpactTotal = Integar (calculated from com.ibm.Impact_cost + com.ibm.Impact_time)

So if Impact1 is Low and Impact 2 is High = Impact Total is 9

My Questions

1.How to put in the Var for the Emuneration literal and the Actual Value required (0 - 9)

2. How to do the calculations based on the ID as I'm going to be adding more ... so want the script to be extendable for any new attributes that starts "com.ibm.impact_"

I've only been able to create a simple add script (using getValue) but have to put in the values (0, 3, 6, 9) not "Low / Medim / High"

I would really appreciate any suggestions to help - if you need clarification then please ask.

Thanks

Matt Muller

 

One answer



permanent link
Ralph Schoon (63.1k33646) | answered Jun 18 '15, 6:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I would really suggest to read through https://jazz.net/wiki/bin/view/Main/AttributeCustomization as well as Process Enactment Workshop for the Rational solution for Collaborative Lifecycle Management
 lab 5. 

If you don't take the time to read through that, you will loose more time in errors and waiting to get the script written in the forum. 

Basically you can get https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript an attribute value and the label. For enumerations the getValue() returns the literal ID ("com.ibm.ImpactLiteral1") and the getLabel() returns the display value "None = 0". 

In your calculation you basically do something with that and then identify the enumeration literal ID to return.

You can use https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Configuring_additional_script_pa to make the script configurable e.g. to read the enumeration ID's to look for.

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.