Share this page

# Example: Object validation

This example demonstrates how you can perform validations of all fields by using the `CanPost` event procedure. For example, this code segment ensures that a user cannot reject a defect without adding a comment.

In this example, a user may not post a defect where the defect status (BG_STATUS) has been changed to `Rejected` unless some explanatory text has been typed in the R&D Comment field (BG_DEV_COMMENTS).

Add the code to the `Bug_CanPost` event procedure so that the check is performed when the user attempts to submit the defect.

VBScript example (supported in Desktop Client only)

Copy code

    Function Bug_CanPost
            ' Initialize the function's return value
         ' to avoid unpredictable behavior.
            Bug_CanPost =  False
            On Error Resume Next
            If Bug_Fields("BG_STATUS").IsModified and _
            Bug_Fields("BG_STATUS").Value = "Rejected" and _
            not Bug_Fields("BG_DEV_COMMENTS").IsModified then
                Bug_CanPost = False
                msgbox "You must enter a comment when rejecting a defect."
            Else
                Bug_CanPost = True
            End If
            PrintError "Bug_CanPost"
            On Error GoTo 0
    End Function

Back to top

https://admhelp.microfocus.com Application Quality Management 8942
Tips to improve your search results... OpenText™ Application Quality Management Help Center OpenText™ Application Quality Management Help Center OpenText™ Application Quality Management Help 26.1 All View Local Help Center View Online Help Center Version: