I Need Quality Center script to pop up 'Enter Comments' message box whenever defect is modified and quits without adding any comments. I would like to make comments is mandatory for each modifications/updation for the defects.
I really appreciate your help
Vishwa is asking for a new comment to be mandatory any time a change is made to the record. Making a field mandatory just means it can't be empty. Once one comment has been added, there will be no further prompts.
The _CanPost function will only execute if changes have been made to the record, therefore we just need to check here if the BG_DEV_COMMENTS field has also been changed:
On Error Resume Next
Defects_Bug_CanPost = Project_DefaultRes
' The fact that this function has been called means that the record has been changed!
' has a new comment been added?
If Field("BG_DEV_COMMENTS").IsModified = False Then
' Get a new comment from the user via Inputbox popup
newComment = InputBox("You need to add a comment before your changes can be saved")
' Make sure the user has entered something
If Len(Trim(newComment)) > 0 Then
' Append the new comment to the record
Bug_Fields("BG_DEV_COMMENTS").Value = Bug_Fields("BG_DEV_COMMENTS").Value & vbcr & newComment
' If no new comment was entered into the input box, don't post.
Defects_Bug_CanPost = False
On Error GoTo 0
You can add formatting, timestamps etc to the comment if you wish, but the above code is a quick 2 minute job that answers your question. Be aware that what you've asked for may irritate your users - a new comment for every single change. You might want to tone this down a bit..
Hi Alex, you mentioned in this post that
"You can add formatting, timestamps etc to the comment if you wish, but the above code is a quick 2 minute job that answers your question" can you show how to add timestamps and the user responsible to comments automatically please? We have an issue of developers not using the 'Add Comment' button which adds their name and date to the comment