the calculated values behavior is not predictable.
i work item type issue ,i have set formulas for effort variance,utilization,test exe productivity,test case preparation productivity.
same i have displayed in front end ,so the logic the creator will give estimated time in hrs and while closing the issue the owned by should be able to fill in the time sheet and thereby the time spent value is been populated by system on its own.
sometime the effort variance is calculated while navigating with in the tab and few other times its not appearing .It same happens to other calculated values too.if i refresh or save also the values are not set sometimes.
effort variance
dojo.provide("com.example.effortvariance");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
dojo.declare("com.example.effortvariance", null, {
getValue: function(attribute, workItem, configuration) {
try {
var estimate= parseFloat(workItem.getValue("duration").trim());
var timespent= parseFloat(workItem.getValue("timeSpent").trim());
var effortvariance = (timespent - estimate)/estimate * 100;
return effortvariance.toString();
}
catch(err) {
var txt;
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.message + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
}
});
})()
|
2 answers
Ralph Schoon (63.5k●3●36●46)
| answered Jul 23 '16, 10:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Jul 23 '16, 10:20 a.m.
You implement a Function. It HAS to return a value. If you don't, don't expect the values to show up. A function that does not return a value is not a function. This all can only happen because JavaScript is an interpreter language without proper compilation.
Also use console.log and not alert. See https://rsjazz.wordpress.com/2016/06/17/javascript-attribute-customization-where-is-the-log-file/ Again see How should I ask a question in the Forum if I want to receive useful answers? for details about what you should have provided if you wanted to help your answer being answered. Maybe check Lab 4 and 5 for an introduction? Also see https://rsjazz.wordpress.com/2016/07/15/rtc-process-customization-what-you-can-and-cannot-do/ for some hints on the limitations of JavaScript. I am also pretty sure that you got the data types for the attributes wrong, which might contribute to the confusiuon. More often than not problems with JavaScript are due to user errors and due to the lack of JavaScript compared with other languages. At least this is my experience. |
The calculated value script depends on attributes "duration" and "timeSpent", so make sure that whatever the attribute you set the script to, its dependencies include these two attributes. Also, these two attributes have to be modified for the script to be triggered. One user found this out in the hard way - see below for details.
https://jazz.net/forum/questions/225348/how-to-get-calculated-attribute-value-script-to-run-in-browser-for-debugging |
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.