It's all about the answers!

Ask a question

How to create a custom javascript provider for RTC


Cédric Mabileau (3847) | asked Jan 08 '14, 12:02 p.m.
edited Jan 09 '14, 2:44 a.m. by Ralph Schoon (63.5k33646)
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;
        },
    });
})();


Comments
Ralph Schoon commented Jan 09 '14, 2:58 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You might want to

  • Be a bit more specific on what you see and what works and what not
  • Try debugging using methods described in the article below (use Chrome, it is easier to use than Firefox

One answer



permanent link
Ralph Schoon (63.5k33646) | 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/ .

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.