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

simple javascript for calculated value of 3 other values in RTC work ticket


Hi all,

 I want to have calculated  value  dependent on 3 other values in work ticket. I came to know that it should be javascript. please let me know how the javascriptshould be. how it should be tested .

 

Thanks,

kavita

1 vote


Accepted answer

Permanent link
Here is an example that operates on two attributes. It uses the attribute ID's to access the data. Follow the link provided by Scott and make sure you read the content. You need to add the attributes that contribute to the calculation as dependent attributes to make sure the script is triggered. Also, please be aware that the scripting has limitations for certain complex attribute types. Int and string type attributes work well, see Scott's link for details.

dojo.provide("org.example.workitems.providers.CalcInteger");

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");


(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("org.example.workitems.providers.CalcInteger", null, {

    getValue: function(attributeId, workItem, configuration) {

        console.log("Start..");
        var text="";
        var out = "Values:\n";
       
        // for integer there should always be a value 0 by default
        var aValue = workItem.getValue("calcInputInt1");
        text = "Value: " + aValue;
        console.log(text);

        // for integer there should always be a value 0 by default
        var aValue2 = workItem.getValue("calcinputint2");
        text = "Value2: " + aValue2;
        console.log(text);
       
        // Was: return aValue+aValue2;
        // parseInt(addMarginVal)+parseInt(costSavingVal)-parseInt(investVal);
        return parseInt(aValue)+parseInt(aValue2);
    }
});
})();
kavita herur selected this answer as the correct answer

1 vote

Comments

Hi, It helped me alot. Still I am not getting trigger part. please help in that context.

Kavita

I am not sure what problem you still have.


4 other answers

Permanent link
@ALL

Finally I cracked this as I was able to achieve what I was looking for... The hunch was on the literal IDs as I found a post where a solution was achieved by altering the literal IDs for all the three dependent attributes..

The script works perfectly as I get the value multiplied for three attributes (enumerations) & the results is displayed in the fourth field (long)

Thanks @Ralph Schoon & @Scott Crouch



1 vote

Comments

Haresh, sorry, I missed your other question. Most issues with accessing attributes are due to the attribute ID's. Also, be aware that several complex attribute types can not really be used in scripts today. Make sure to select the other attributes as dependent attributes for your script.


Permanent link
Check out this wiki:  https://jazz.net/wiki/bin/view/Main/AttributeCustomization

0 votes


Permanent link

@Scott Crouch

 

Thanks for the link.I followed the link and tried the same kind of steps as per my req as I too have a same requirement, which involves 3 enumerated attributes, the 3 values (from 1 to 10) has to be multiplied and the result must be displayed in the fourth (Read-only) INT attribute....it is not quite clear when will the value be calculated and displayed..

It is not happening for my case as well...

 

@Ralph Schoon

 

My concern is that ... adding the dependencies for the specific attribute is enough for the calculated values to work...or does that require any more triggers...

 

Also I observed so many posts saying the Version 3.0.1 and so on of RTC does not support the Calculated Values...Is that so.??

 

Thanks,

HaresH

 

 

 

0 votes


Permanent link

I was wondering if it is possible to hide an attribute based on a value coming from an attribute?

For example, I have an attribute "Development Type". It contains Project/Defect/Demand.  If I select Project, I will make an attribute "Project" visible.

0 votes

Comments

@ Canberk Akduygu :

Guess your question is not related to the issue which I had... Also I am not sure on how ur requirement can be done..

Canberk, you can use a JavaScript based condition and a precondition available in RTC 4.x to make things read only or required. I don't think you can hide it though.

Can anyone of the people who asked the questions accept an answer?

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
× 6,130

Question asked: Jun 11 '12, 6:23 a.m.

Question was seen: 8,460 times

Last updated: Mar 21 '13, 11:47 a.m.

Confirmation Cancel Confirm