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

Dojo Script for division || for Customized dicimal fileds

 Hi, I am able to use Dojo Script for addition and multiplication, but now sure how to do a division

 for e.g. I am using a script for addition  field1 + filed 2,  (10 +2=14)

but not able to do filed1/filed2 , ( 10/2=5). <o:p> </o:p>

 please suggest.

0 votes



One answer

Permanent link

 Hi,


  I tried a simple code here and the division works normally.

return workItem.getValue("test_num_1")/workItem.getValue("test_num_2");



 Try to use a try/catch to see if there is some exception... Like this:

        getValue: function(attribute, workItem, configuration) {
        try {
  var num1 = workItem.getValue("test_num_1");
var num2 = workItem.getValue("test_num_2");

var sum = 0;
if (!isNaN(num1) && !isNaN(num2)) {
  sum = num1/num2;
} else {
  sum = "";
}  
return sum;
} catch (err) {
            return err.message;
}
        }


 You might want to use the Number() method to force/parse the value into a Number value.

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
× 12,024

Question asked: May 04 '17, 7:17 a.m.

Question was seen: 1,860 times

Last updated: May 04 '17, 10:08 a.m.

Confirmation Cancel Confirm