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.

    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

https://admhelp.microfocus.com ALM 8942
Tips to improve your search results... ALM Help Center ALM Help Center ALM Help 15.5-15.5.1 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: