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
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
/**
* 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;
}
});
})();
One other answer
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;
}
});
})();
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;
}
});
})();