Assigning current Time Stamp upon closure of defects
I'm currently working with RQM 3.0
A new field "Closing_Date" in defects is added to capture closing date of the defect.
It would be a mandatory field when user tries to move defect to "CLOSED" status.
But, while doing so it should pick up the current time stamp.
I heard that this can be achieve with a Dojo script?
Any guidance on this please.....
Thanks
3 answers
In general the answer to your question is to edit the RTC project area process configuration via the Eclipse client:
1. Create a script based calculated value
2. Create a new timestamp attribute for the defect work item
3. Select the script created in step 1 in the "Calculated Value" dropdown of the new attribute
4. Configure the new attribute to have a dependency on the "Status" attribute.
5. Add a read only presentation for your new attribute to the defect editor
This post contains a good sample script that manipulates dates. Your script will need to be modified, for example to take the state of the workitem into account.
https://jazz.net/forum/questions/83120/how-to-show-the-difference-between-current-date-and-due-date-through-script-based-calculated-value
Comments
Brian, as far as I can tell, there is no easy way to detect the state change using scripts. If you have an idea, please share it. So far you can only read the current state .
I think we can do this without detecting the state change in the script. If the new attribute is configured to have a dependency on "Status", the script will re-execute every time there is a state change. Then, you can add an if switch in the script to only return a value when the workitem is resolved, like below. A good exercise for the reader is to figure out how to clear the value if the workitem gets re-opened.
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var currentDate= new Date();
if (workItem.getValue(WorkItemAttributes.STATE)=="3") {
return currentDate.getTime().toString();
}
return 0;
Hi Brian, OK, that might work if the State attribute is the only dependency. Thanks for the hint.
Brian,
I tried the similar procedures and scripts as suggested and it does not work. When state changed to resolved, the custom attribute remains as None. I posted the question here:
https://jazz.net/forum/questions/162999/assigning-current-time-stamp-when-defect-is-resolved
Do you know what could be wrong? Thanks
And to follow the same behavior like "resolution date" I make the field read only on the presentation.
-----------------
dojo.provide("com.example.ValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.example.ValueProvider", null, {
getValue: function(attribute, workItem, configuration) {
var currentDate= new Date();
if (workItem.getValue(WorkItemAttributes.STATE)=="6") {
return currentDate.getTime().toString();
}
return 0;
}
});
})();
-------------------