Example: Changing One Field Based on Another Field

This example demonstrates how you can change a field value based on the value entered into another field.

For example, you can cause defects to be assigned to user alex_qc when UI Suggestion is typed into the Category field, and to user alice_qc when Security Issues is typed.

The example assumes that the user-defined field BG_USER_05 is used to store the category. When the Category field is changed in the Defects module, the BG_RESPONSIBLE field is assigned the appropriate value.

Add the code to the Bug_FieldChange event procedure so that it is triggered when a user changes a field value for a defect.

Sub Bug_FieldChange(FieldName)
        On Error Resume Next
        If FieldName = "BG_USER_05" then
            Select case Bug_Fields("BG_USER_05").Value
            case "UI Suggestion"
            case "Security Issue"
            Case Else
            End Select
        End If
        PrintError "Bug_FieldChange"
        On Error GoTo 0
End Sub