It's all about the answers!

Ask a question

Calculated Value Script: workItem.getValue() Returns Zero


Daniel Chirillo (1801623) | asked Mar 07 '12, 6:45 p.m.
Environment: RTC 3.0.1.2.

Background: I'm developing a calculated value script, which itself is an attempt to work around a limitation. I want a field to be read-only once the WI progresses out of the New state. Since we can't do that yet, my idea is to hide the field once the WI moves beyond New and to have a shadow read-only field that reads and displays the value of the field I'm hiding.

The issue: whenever the script (code below) reads an attribute.....Integers come back with a value of zero and DateTimes (which I'm doing in another script) come back null. I'm only able to successfully read Enumerations.

Any thoughts?


***************************************
dojo.provide("com.moi.workitems.providers.CopyInitPlannedNumTestCases");
dojo.require("com.moi.team.workitem.api.common.WorkItemAttributes");


(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.moi.workitems.providers.CopyInitPlannedNumTestCases", null, {
getValue: function(attributeId, workItem, configuration) {

console.log("Entering CopyInitialPlanned()");
var initialPlanned = workItem.getValue("com.moi.workitem.attribute.initialPlannedNumTestCases");
console.log("Initial Planned number: " + initialPlanned);

return initialPlanned;
}
});
})();

3 answers



permanent link
Ralph Schoon (63.1k33645) | answered Mar 08 '12, 2:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Daniel,

did you add the attributes, especially the others, as dependent attributes?

permanent link
Karthikeyan Elangovan (3644) | answered May 07 '12, 1:07 p.m.
Hi Daniel,

Environment: RTC 3.0.1.2.

Background: I'm developing a calculated value script, which itself is an attempt to work around a limitation. I want a field to be read-only once the WI progresses out of the New state. Since we can't do that yet, my idea is to hide the field once the WI moves beyond New and to have a shadow read-only field that reads and displays the value of the field I'm hiding.

The issue: whenever the script (code below) reads an attribute.....Integers come back with a value of zero and DateTimes (which I'm doing in another script) come back null. I'm only able to successfully read Enumerations.

Any thoughts?


***************************************
dojo.provide("com.moi.workitems.providers.CopyInitPlannedNumTestCases");
dojo.require("com.moi.team.workitem.api.common.WorkItemAttributes");


(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.moi.workitems.providers.CopyInitPlannedNumTestCases", null, {
getValue: function(attributeId, workItem, configuration) {

console.log("Entering CopyInitialPlanned()");
var initialPlanned = workItem.getValue("com.moi.workitem.attribute.initialPlannedNumTestCases");
console.log("Initial Planned number: " + initialPlanned);

return initialPlanned;
}
});
})();



For custom attributes you need to configure custom tag in process configuration source of your respective project area.
Your script should be modified to :

dojo.provide("com.moi.workitems.providers.CopyInitPlannedNumTestCases");

(function() {

dojo.declare("com.moi.workitems.providers.CopyInitPlannedNumTestCases", null, {
getValue: function(attributeId, workItem, configuration) {

console.log("Entering CopyInitialPlanned()");
var initialPlannedTCs = configuration.getChild("initialPlannedTCs").getIdentifier();

var initialPlanned = workItem.getValue("initialPlannedTCs");
console.log("Initial Planned number: " + initialPlanned);

return initialPlanned;
}
});
})();

permanent link
Karthikeyan Elangovan (3644) | answered May 07 '12, 1:09 p.m.
Add the following custom tag next to <script> tag in process configuration source as follows.

<valueProvider....>
<script class=""/>
<initialPlannedTCs id=""/>
</valueProvider>

Your answer


Register or to post your answer.