It's all about the answers!

Ask a question

Can I Generate Other Attributes that Pull "Current Date" when State Changed?

Rob Olsen (3512153) | asked Aug 10 '16, 10:02 p.m.
Creation Date is automatically created when someone creates a Work Item within RTC.  Is there a way that I can have other attributes (i.e. "Assigned Date", "Start Date", etc), that get set automatically like "Creation Date" when the state is changed and Save is selected?  For example, we would like to track when a Work Item is assigned.  We have a state called "Assigned".  When state "Assigned" is selected and "Save" is clicked, can a Timestamp attribute called
Assigned" be set by the current date/time?

One answer

permanent link
Ralph Schoon (63.3k33646) | answered Aug 11 '16, 2:20 a.m.
There are ways to do that. The question has in one or another form being asked a lot of times already. See for some of the questions and answers.

My summary:

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:

In JavaScript Attribute customization, you can only see the action in conditions, where you can't use them to set an attribute.

As far as I can tell, the only way users have been able to detect a state change in calculated value providers so far was, by storing the state in a hidden custom attribute (maybe boolean works as well) and detecting the state change by comparing the value there and the new state value (which this attribute is dependent upon). Store the new state and let that trigger another script dependent on this attribute.

The other calculated attribute provider depends on that. If the value changes and the state is the one you want to count, you could save the date, I suppose. Your attribute would only be recalculate if a state changes and you could return the old date as long as the state (in the hidden attribute) is not the one you are interested in.

I have never tried that, especially because attribute customization

does not run in the visual studio client, the shell and in any automation

so, if you want something accurate, a work item save (server) follow up action is the better, more reliable choice.

Rob Olsen commented Aug 11 '16, 9:52 a.m. | edited Aug 11 '16, 9:56 a.m.

Thanks Ralph, I was hoping it was much simpler since "Created Date" seems to work with the initial saving of a Work Item.  I was hoping to do something similar and just compare a state change and when that occurred capture the current date/time in the custom attribute. 

Appreciate your time to respond.  Will have to have the customer just click on the attribute and select the current date/time for now.  Will look at the cooler implementation at a later time.

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.