I want to use a Calculated field to sum an attribute from all children.
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
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
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