Check if a Dialog Box is Open
It is helpful to track whether a dialog box is open before performing certain actions. For example:
-
Dialog boxes do not need to be refreshed but grid displays do.
-
Certain workflow events are not allowed when a dialog box is open.
The DialogBox event can be used to track the visibility of dialog boxes.
Recommendations
To avoid unpredictable results, determine if a dialog box is open before any events occur.
The following example checks whether the dialog box for creating a new defect is open. This is relevant because the BG_USER_01
field can only be modified for a new defect. If a different dialog box is open, such as the dialog box for editing a defect, the BG_USER_01
field cannot be modified.
Example:
' Declare a global variable for each dialog box of interest Dim NewDefectDialogIsOpen ' Initialize the global variable NewDefectDialogIsOpen = False Sub DialogBox(DialogBoxName, IsOpen) If DialogBoxName="New Bug" Then NewDefectDialogIsOpen = True Else NewDefectDialogIsOpen = False End If End Sub Function Bug_FieldCanChange(FieldName, NewValue) ' Initialize the function's return value to avoid ' unpredictable behavior. Bug_FieldCanChange = True ' The BG_USER_01 field can only be modified for a new defect. If FieldName="BG_USER_01" Then If NewDefectDialogIsOpen Then Bug_FieldCanChange = True Else Bug_FieldCanChange = False End If End If End Function