Capturing the date when state changes in RTC
Hi,
We are having a field called "Defect Resolution date" in Defect work item. We have return a dojo script to capture the current time stamp when defect work item change to Fixed state. Its working fine....it is capturing the time stamp when defect comes to Fixed state. However this timestamp changes when the attribute values are modified like example comments field or any change to it, in the same state "Fixed " too. This should not be the case. It just change the date agian in the same state when ever change on field value and save operation. So is there any way i can change my script condition to achieve this. Thanks in advance...! dojo.provide("com.example.defectresolutiondateCalculationValueProvider"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); dojo.require("dojo.date.stamp"); // -------------------------------------------------------------------------------- // Calculate the Ready For Review Date. When a Review work item goes into Ready For Review status, then set // the date to the current timestamp. // If the defect has any other status, then set the Review Date to some bogus value. // -------------------------------------------------------------------------------- (function() { var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes; dojo.declare("com.example.defectresolutiondateCalculationValueProvider", null, { getValue: function(attributeId, workItem, configuration) { // Log messages go to: Eclipse client: client/eclipse/workspace/.metadata/.log console.log("com.example.dateCalculationValueProvider - Entry"); // Get the current timestamp, and convert it to an ISO-8601 string var ModifiedDate = new Date(); console.log("Modified Date = " +ModifiedDate); var ModifiedDateString= dojo.date.stamp.toISOString(ModifiedDate, {milliseconds:true, zulu:true}); console.log("Modified Date String = " +ModifiedDateString); var ReviewStatus = workItem.getValue(WorkItemAttributes.STATE); console.log("com.example.dateCalculationValueProvider: ReviewStatus: '" + ReviewStatus + "'"); // If the state is Ready For Review if ( ReviewStatus == "NewDefectWorkflow.state.s2" ) { return ModifiedDateString; } else { //var retestDate = dojo.date.stamp.toISOString(workItem.getValue("retesting_date")); //console.log("current constraint date is "+retestDate); console.log("set old date back"); return workItem.getValue(attributeId); } console.log("com.example.dateCalculationValueProvider - Exit: Review date returned is '" + ModifiedDateString + "'") } }); })(); |
Accepted answer
unfortunately, in javascript, you cannot see what the status was BEFORE.. only after..
so, your script updates the date everytime, you only want to set the date on the transition from not fixed to fixed status. to do that , you will have to write a server side java Participant. see the workshop for creating extensions. https://jazz.net/library/article/1000 Vijayveer Reddy selected this answer as the correct answer
|
One other answer
There might be 3 types of a solution for you.
1: Easiest way to achieve what you want would be a boolean value. You set it false in every other state and set it true when you have the wished state. 2: You "read" the time you've setted. If there's some value in it. Don't change it. 3: There are states and actions(Those are who changes the state). It would be better to catch the action instead the state itself. In that case you exactly know what state the Item had and going to have. Comments 1
Ralph Schoon
commented Jan 15 '16, 8:55 a.m.
| edited Jan 15 '16, 9:00 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
In JavaScript Attribute customization, you can only see the action in conditions, where you can't use them to set an attribute.
Jonas Studer
commented Jan 15 '16, 9:28 a.m.
Antoher Idea could be to read in the history the last entry.
I am not aware that you have access to the work item history using the attribute customization JavaScript API. As far as I am aware all you can do is read attributes - the current state.
Jonas Studer
commented Jan 15 '16, 10:18 a.m.
Yep.. The History isnt direct in the workitem.
Ralph Schoon
commented Jan 15 '16, 10:39 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please provide a working attribute customization provider (e.g. something that uses this and calculates and returns the result shown into the console or as text so you can show it in the description.
Ralph Schoon
commented Jan 15 '16, 10:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
PS, you have my e-mail.
showing 5 of 6
show 1 more comments
|
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.
Comments
I am interested in automatically capturing work item state transition date too.
Did you manage to get this feature work in RTC ? If so did you use “Calculated Value” (see attached screenshot) calling into custom Java Script ? It would be great help if you are able to share the Java Script.
Thanks for your help in advance.