Share this page

# Example: Field Validation

This example demonstrates how to validate a single field value. For example, the following code segment shows how you can ensure that a user in a specific group cannot lower the priority of a defect.

In this example, if the user is in the `QATester` group and the BG_PRIORITY field is being modified, the new value of the BG_PRIORITY field cannot be lower than the current value.

This example assumes that in the Priority field list for the project, lower priorities come first when the values are sorted in ascending order. For example, the list meets this requirement if the elements are as follows:`1-Low, 2-Medium, 3-High`.

Add the code to the `Bug_FieldCanChange` event procedure so that it is triggered when the user attempts to change a defect field value.

VBScript example (supported in Desktop Client only)

Copy code

    Function Bug_FieldCanChange(FieldName, NewValue)
            ' Initialize the function's return value
        ' to avoid unpredictable behavior.
            Bug_FieldCanChange = True
            On Error Resume Next
            If User.IsInGroup("QATester") and FieldName ="BG_PRIORITY" _
         Then
                If NewValue < Bug_Fields("BG_PRIORITY").Value then
                    Bug_FieldCanChange = False
                    msgbox "You do not have permission to lower " _
             & "defect priority."
                Else
                    Bug_FieldCanChange = True
                End If
            Else
                ' Enter your code here.
            End If
            PrintError "Bug_FieldCanChange"
            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: