Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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

1 vote


Accepted answer

Permanent link
/**
* 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

1 vote

Comments

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

Hi Ralph

Yes please do so

Thx


One other answer

Permanent link
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;
    }
});
})();

1 vote

Your answer

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 6,131

Question asked: Jul 03 '12, 7:52 a.m.

Question was seen: 5,847 times

Last updated: Apr 18 '13, 7:32 a.m.

Confirmation Cancel Confirm