Get amount of time a WI has been in a given state? (javascript)
I've looked at this other question and building up on it.=
https://jazz.net/forum/questions/180890/defect-age-by-state
Not sure if anyone has done this yet, but the problem that I'm encountering is that the current time doesn't refresh when the page gets refreshed.
I've used both getTime() and Date.now() and it is the same thing. The date only gets refreshed when you change the state of the WI instead of automatically every time you refresh the page.
You can see this when you run a simple customized attribute with the following javascript
dojo.provide("com.example.GetTurnAroundTime");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
(function() {
dojo.declare("com.example.GetTurnAroundTime", null, {
getValue: function(attribute, workItem, configuration) {
try {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var currentDate= Date.now();
if(currentDate != null)
return currentDate.toString();
}
}
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
(function() {
dojo.declare("com.example.GetTurnAroundTime", null, {
getValue: function(attribute, workItem, configuration) {
try {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var currentDate= Date.now();
if(currentDate != null)
return currentDate.toString();
}
}
});
})();
})();
The end goal is to calculate how long the WI has been under a certain state, but this is the first step in solving this problem.
Any help or input would be appreciated.
Accepted answer
It is very hard to reliably detect a state change in an attribute customization. It would be necessary to store a state in a hidden attribute and use that to determine the state actually changed. I think it would be better to use a custom work item save follow up action/participant, as that can reliably detect a state change. Here some examples how they wold look like: https://rsjazz.wordpress.com/?s=participant
One other answer
That's not possible. You want to change an attribute but you don't want to save the change, aren't you contradicting yourself?
You may have in mind something like the countdown clock on some auction sites, but such feature does not exist in RTC.
You may have in mind something like the countdown clock on some auction sites, but such feature does not exist in RTC.
Comments
Daniel Flores Montanez
Jun 01 '16, 12:21 p.m.Daniel Flores Montanez
Jun 01 '16, 12:24 p.m.