simple javascript for calculated value of 3 other values in RTC work ticket
kavita herur (58●7●68●94)
| asked Jun 11 '12, 6:23 a.m.
edited Mar 21 '13, 11:47 a.m. by Ralph Schoon (63.5k●3●36●46)
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 |
Accepted answer
Ralph Schoon (63.5k●3●36●46)
| answered Jun 11 '12, 8:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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
Comments
kavita herur
commented Jun 12 '12, 7:07 a.m.
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
@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 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. |
|
@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
HARESH KRISHNAN
commented Aug 13 '12, 2:14 a.m.
@ 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..
Ralph Schoon
commented Mar 21 '13, 11:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.
|
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.