How to add custom field that populates with date and time stamp when defect status goes to fixed?
Question ID: 107752
1
0

I would like to add a custom field to defects, and have it be set to auto populate the date and time for when the defect status is changed to fixed. Say new field is called Fixed Date, and when dev changes the status to Fixed, Fixed Date gets the date and time stamp added. How can I do this?

Marked as spam
Posted by (Questions: 26, Answers: 22)
Asked on July 21, 2017 6:19 pm
42 views
Answers (1)
1
Private answer

Hello,

This is pretty easy to achieve. Enter the project customization, go to Project Entities, find Defect and expand it out to show the System and User Fields. Click on User Fields folder and above select New Field. Create your ''Fixed Date'' field (type string). Note the DB name given. For my below example, BG_USER_01 was my field created.

![alt text][1]

Save your edit and then click on Workflow and open the Script Editor.

On tree to the left, expand the Defects module script section.

While you can skip this, for my example I went ahead and added code to Bug_New and Bug_MoveTo to have the new field ''Fixed Date'' be read only. I didn't want anyone to enter any data here so I have it read only until properly triggered (meaning trigger on when Status changes to Fixed).

Sub Bug_New
On Error Resume Next
Bug_Fields.Field(''BG_USER_01'').IsReadOnly = True
On Error GoTo 0
End Sub

Sub Bug_MoveTo
On Error Resume Next
Bug_Fields.Field(''BG_USER_01'').IsReadOnly = True
On Error GoTo 0
End Sub

After adding that, the real code you want is the trigger on Status. Add this to the Bug_FieldChange sub.

Sub Bug_FieldChange(FieldName)
On Error Resume Next
If Bug_Fields.Field(''BG_STATUS'').IsModified and Bug_Fields.Field(''BG_STATUS'').Value = ''Fixed'' then
Bug_Fields.Field(''BG_USER_01'').IsReadOnly = False
Bug_Fields.Field(''BG_USER_01'').Value = TDConnection.Servertime
Bug_Fields.Field(''BG_USER_01'').IsReadOnly = True
End if

On Error GoTo 0
End Sub

This code will trigger a populate then for data and time stamp when the status is changed to Fixed, and then put the field back to read only.

Here is a defect created with New status, see the ''Fixed Date'' field is read only and not populated.

![alt text][2]

Now here is a pic of the status changed to Fixed and the ''Fixed Date'' field now having auto populated.

![alt text][3]

Now you have the field you want with the data you want, triggered for when status = Fixed.

[1]: /storage/temp/634-fixed-date.png
[2]: /storage/temp/637-bug-new-status.png
[3]: /storage/temp/638-bug-fixed-status.png

Marked as spam
Posted by (Questions: 1, Answers: 116)
Answered on July 21, 2017 6:41 pm
0
just what I wanted
( at July 21, 2017 6:33 pm)
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top