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

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

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.


0 votes

Comments

 I've noticed that the time gets updated every time you save, not necessarily with change of states.


I would still want it to be automatic instead of the the time having to rely on saving the work item each time.

 I've just noticed the time changes every time you save the work item. It actually has nothing to do with the state change, but it still needs to be saved.


I would want it to update every time the page gets refreshed and not necessarily saved


Accepted answer

Permanent link
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
Ralph Schoon selected this answer as the correct answer

0 votes


One other answer

Permanent link
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.

0 votes

Comments

Not necessarily .. for example you can have 2 input decimal attributes that multiply into a 3rd decimal output attribute.

The third attribute will have those other 2 as dependencies.

When you type in any numbers into the 2 input attributes. The third will display in real time.
this is what i want for time. to alway update without saving. almost like a countdown.
This works if you set time as a string, but not a timestamp

 Hi Daniel

I think what are youtrying to do is not possible, at least the way you are thinking.

You are assigning the value of Now(); to an attribute. But that assignment it is done when you save the workitem. So you will need to save the workitem.
You can store in hidden attributes the dates that the state changes. For example
Get state1 and state2 dates and then you do a math.

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
× 10,937
× 457
× 152

Question asked: Jun 01 '16, 11:22 a.m.

Question was seen: 4,441 times

Last updated: Jun 30 '17, 12:50 p.m.

Confirmation Cancel Confirm