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.

    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

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: