Does anyone have any workflow code that could be used to make it so that testers could not edit or delete previous users R&D defect comments?
Answer by Josh_Yates · Jan 24, 2013 at 03:19 PM
Yes this is possible, the best way to do this would be by using two fields, in this example, a new memo field in the defects module will need to be created. In this example this new defect memo field will be called “BG_USER_25”. The other field that this code deals with is the “BG_DEV_COMMENTS” which is the regular defects comment field. All new comments will need to be added using the new memo field that you create, then a user stamp and date/time stamp is added and combined with the existing comments. After the new comment is added to the existing comments, the new comment memo field is cleared. The users will need to learn that to add new defect comments that they are added from the "New Comment" memo field and not the regular comment field.
Note: Please test this code on a test project before implementing on a large scale, since all projects in QC are different unexpected results could occur.
Add the following to the Bug_fieldchange and bug_moveto subroutines, replacing the "BG_USER_25" with the new memo field that you created for entering the new comments.
Sub Bug_FieldChange(FieldName) On Error Resume Next if Bug_Fields.Field("BG_User_25").IsModified=true then NewComment = "<br>" & user.UserName & "" & date() & "" & time() & ":" & Bug_Fields.Field("BG_User_25").Value PreviousComment = Bug_Fields.field("BG_DEV_COMMENTS").value CombinedComment = PreviousComment + NewComment Bug_Fields.Field("BG_DEV_COMMENTS").IsReadOnly = False Bug_Fields.Field("BG_DEV_COMMENTS").value = CombinedComment Bug_Fields.Field("BG_DEV_COMMENTS").IsReadOnly = True Bug_Fields.Field("BG_User_25").value = "" End If On Error GoTo 0 End Sub Sub Bug_MoveTo On Error Resume Next Bug_Fields.Field("BG_DEV_COMMENTS").IsReadOnly = True On Error GoTo 0 End Sub