It's all about the answers!

Ask a question

I want to use a Calculated field to sum an attribute from all children.


Rodrigo Belli (113) | asked Apr 12 '16, 5:56 p.m.
Hello Folks,

I'm using Agile in RTC and have Story(parent) and Tasks (children) so, I'm trying to create a new calculated field in Story to show the sum of all hours spent in the tasks (tasks are children of an Story - always).

My problem is that I can't to get the Tasks(children) associated in a Story(Parent)

I used this script to check if RTC will get the number of child right, but the result is always 0;

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

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.TotalHoursAssociated", null, {

    getValue: function(attributeId, workItem, configuration) {
   
   var allTasks = configuration.getChildren();
  
   return allTasks.length;
    }
});
})();

What I'm doing wrong?

Someone could help me?

Thanks in advance.

2 answers



permanent link
Ralph Schoon (63.1k33645) | answered Apr 13 '16, 2:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
As far as my experience goes you can't traverse links in the published JavaScript API that works in the Web UI and the Eclipse client. You can do something like that using Java. See https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/

permanent link
Donald Nong (14.5k414) | answered Apr 12 '16, 8:30 p.m.
edited Apr 12 '16, 8:54 p.m.
The "configuration" element is part of the (process) customization configuration, and is "static" during runtime. See below sample in the API reference - pay attention to the way "greeting" is configured. Likewise, you will need such configuration in order to return anything for the call configuration.getChildren().
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_Example

Note that the "children" relationship in your mind is essential a "link" between work items, which in my knowledge is not supported.

Edit: someone asked a similar question in the past, and the answer was similar.
https://jazz.net/forum/questions/105450/how-to-get-parent-work-item-attribute-value-in-dojo-script-to-rtc-project-area

Your answer


Register or 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.