simple javascript for calculated value of 3 other values in RTC work ticket
Accepted answer
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);
}
});
})();
4 other answers
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
@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
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.
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?