Answer by Captain Mercury · Feb 24, 2010 at 06:23 PM
When adding an R&D comment to a defect, it would be beneficial to have the system also add a timestamp to the comments added. There is a documented HP KB article that provides a script that will add a timestamp, but it does not retain the original function (bolded blue text, line seperating each comment, etc.) This one does. Code provided with no warranties...
' BEGIN CODE
On Error Resume Next
ActionCanExecute = DefaultRes
If ActionName="AddDevComment" or ActionName="BugAddDevCommentsAction1" then
dim DescriptionBefore dim ServerTime dim UserStr
DescriptionBefore = Bug_Fields("BG_DEV_COMMENTS").Value
if Len(DescriptionBefore) = 0 then DescriptionBefore = "<html><body>" else DescriptionBefore = DescriptionBefore + "<br><strong><font color=#000084><br></font></strong>" end if
UserStr = User.FullName + " <" + User.UserName + "> " ServerTime = CStr(TDConnection.ServerTime)
'Start R&D comments
DescriptionBefore = DescriptionBefore + "<strong><font color=#000084>" DescriptionBefore = DescriptionBefore + UserStr + ", " DescriptionBefore = DescriptionBefore + ""+ServerTime+"" DescriptionBefore = DescriptionBefore + "</font></strong>" + ": <font color=#000000>" + "<br>"
'End R&D Comments
DescriptionBefore = DescriptionBefore + "</font></body></html>" Bug_Fields("BG_DEV_COMMENTS").Value = DescriptionBefore ActionCanExecute = False
On Error GoTo 0 End Function
' END CODE
Answer by Sandhu · May 28, 2010 at 02:13 AM
You can retain the formatting of existing Comments. Since the comments are embeded inside html Code, we need to retain the HTML code. Add the following Command after opening the QC connection: "Connection_Name".IgnoreHtmlFormat = False
Here connection_Name is the name of QC Connection Object. This statement will enforce the Connection to retain all HTML formatting...
Hopefully I will help....
Answer by neha1705 · Sep 17, 2013 at 11:43 AM
This code is really helpful. but there is another question on it. after adding this code, comment gets added with username and timestamp but cursor goes to top of the textarea. how can i set the cursor at the end of the comment area?