How to create a custom javascript provider for RTC
![]()
Cédric Mabileau (38●4●7)
| asked Jan 08 '14, 12:02 p.m.
edited Jan 09 '14, 2:44 a.m. by Ralph Schoon (60.5k●3●36●43)
Hello,
I am trying to create a custom provider in order to calculate a risk exposure (the risk exposure already in place doesn't suit my needs). In order to do that, i inspired my javascript on a video i found (http://dl.dropboxusercontent.com/u/2663305/Movies/rtc-2.0.0.2-attribute-value-providers.m4v around 4 minutes in) and i came up with the script copied at the end of my message. I created the attributes with ID severitylevel and frequencylevel, they are both enumeration that go from 1 to 5. I specified in my risklevel attribute that they are dependencies, my risklevel attribute is an integer type. However, i can't get this to work, if you have any idea i would be grateful if you could share them with me. Best regards, Cédric Mabileau Source code for my javascript : dojo.provide("com.example.RiskProvider"); (function() { dojo.declare("com.example.riskProvider", null, { getValue: function(attribute, workItem, configuration) { var severityAttribute= configuration.getChild("severitylevel").id; var frequencyAttribute= configuration.getChild("frequencylevel").id; var severity = this.__getLastIntSegment(workItem.getvalue(severityAttribute)); var frequency= this.__getLastIntSegment(workItem.getvalue(frequencyAttribute)); var riskInteger= severity * frequency switch (riskInteger ) { case riskInteger > 12: var risk= 1; break; case ((riskInteger < 12) && (riskInteger > 9)) : var risk= 2; break; case ((riskInteger < 9) && (riskInteger > 5)): var risk= 3; break; case riskInteger = 4: if (severity = 4) { var risk = 3; } else { var risk =4; } break; case riskInteger < 3: var risk= 4; break; return risk; }, __getLastIntSegment : function(identifier) { if (identifier != null) { var lastSeparator= identifier.lastIndexOf('.'); var numberString= identifier.substring(lastSeparator+1); return parseInt(numberString, 10); } return -1; }, }); })(); |
One answer
![]()
Ralph Schoon (60.5k●3●36●43)
| answered Jan 09 '14, 2:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You might want to look into https://jazz.net/library/article/1093 Lab 5. This might be able to give you the information you need. You can also consider to use Java instead of JavaScript as described in https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ .
|
Comments
You might want to