It's all about the answers!

Ask a question

How do I automate setting remaining work to '0' when the state of a task is set to DONE ?


Erwin Kunz (94687086) | asked Jul 03 '12, 7:52 a.m.
edited Jul 03 '12, 8:13 a.m. by Geoffrey Clemm (30.1k33035)
I would like to force the Remaining Work to ZERO when the developer sets the Task to DONE

I didn't found anything in the process configuration. Only thing I saw, would be creating a script and include it as Follow-up action. What is for me a bit high-end :-(

If somebody has a real example of setting an attribute on state change he could share with me. With all installation instruction for dummies :-) it would be great

Thanks
erwin

Accepted answer


permanent link
Erwin Kunz (94687086) | answered Mar 15 '13, 8:55 a.m.
/**
* Script used to force the remaining hours on task when DONE.
* This is done by setting the Time Spent equal the Effective Estimate
*
* com.ibm.team.workitem.attribute.duration : ESTIMATE
* com.ibm.team.workitem.attribute.correctedestimate : CORRECTED ESTIMATE
* com.ibm.team.workitem.attribute.timespent: TIME SPENT
*
*/
dojo.provide("com.siemens.sbt.workitems.providers.timespent");

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("com.siemens.sbt.workitems.providers.timespent", null, {
getValue: function(attribute, workItem, configuration) {
var result = workItem.getValue(WorkItemAttributes.TIME_SPENT);
var typevar = workItem.getValue(WorkItemAttributes.TYPE);

if(typevar=="task"){
var statevar = workItem.getValue(WorkItemAttributes.STATE);
var estimatevar = workItem.getValue(WorkItemAttributes.ESTIMATE);
var corestimatvar = workItem.getValue(WorkItemAttributes.CORRECTED_ESTIMATE);

if ((statevar == "com.siemens.btq.task.state.s1") || (statevar == "com.siemens.btq.task.state.s5")){ /*DONE || OBSOLETE*/

result= estimatevar;
if (corestimatvar > 0){
result= corestimatvar;
}
}

}
return result;

}
});
})();
Ralph Schoon selected this answer as the correct answer

Comments
Ralph Schoon commented Mar 15 '13, 9:12 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Great Erwin! Please let me know if I shall accept this answer as accepted answer.


Erwin Kunz commented Apr 18 '13, 7:32 a.m.

Hi Ralph

Yes please do so

Thx

One other answer



permanent link
Ralph Schoon (63.6k33646) | answered Jul 05 '12, 7:13 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 05 '12, 7:14 a.m.
Hi Erwin, I tried it with a scripted value provider https://jazz.net/wiki/bin/view/Main/AttributeCustomization and it did NOT work.

I am assuming, since the scripting interface is still very limited, I can not read or write the duration, so the script below does not work.

I would assume you have to write a follow up action. https://jazz.net/library/article/634 shows how to do that. your case is very simple and should be easy enough to do. Here is another article with a good overview https://jazz.net/library/article/784


This does unfortunately NOT work:


/*******************************************************************************
 * Licensed Materials - Property of IBM
 * (c) Copyright IBM Corporation 2012. 
 * 
 * Note to U.S. Government Users Restricted Rights:  Use,
 * duplication or disclosure restricted by GSA ADP Schedule
 * Contract with IBM Corp.
 *******************************************************************************/

dojo.provide("com.ibm.js.rtc.wi.valueprovider.calculated.timeremaining");

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("com.ibm.js.rtc.wi.valueprovider.calculated.timeremaining", null, {

    getValue: function(attributeId, workItem, configuration) {
        console.log("Start..");
        var aState= workItem.getValue(WorkItemAttributes.STATE);
        var timeremainig = workItem.getValue(WorkItemAttributes.TIME_SPENT);
           //  var time = dojo.date.stamp.fromISOString(timeremainig);
           // dojo.date.stamp.toISOString(0, {milliseconds:true, zulu:true});
        console.log("State: [" + aState + "]");
        console.log("timeremaining: [" + timeremainig + "]");
        console.log("timeremaining: [" + time + "]");
   
        // New
        if (aState == "1") return timeremainig;
        // In Progress
        if (aState == "2") return timeremainig;
        // resolved
        if (aState == "3") parseInt("0");
        // ReOpen
        if (aState == "6") return timeremainig;
        // Verified
        if (aState == "4") return timeremainig;
        // No state
        if (aState == "") return timeremainig;
        // No Match
        return timeremainig;
    }
});
})();

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.