Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to create a custom javascript provider for RTC

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;
        },
    });
})();

0 votes

Comments

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
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/ .

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937
× 8

Question asked: Jan 08 '14, 12:02 p.m.

Question was seen: 4,874 times

Last updated: Jan 09 '14, 2:58 a.m.

Confirmation Cancel Confirm