I created a button in ALM Defect module in a clean project. the code is as follows:

Function ActionCanExecute(ActionName)
On Error Resume Next
ActionCanExecute = True
If ActionName = "UserDefinedActions.Defect_Action1" Then
MsgBox "You clicked the Action1 button."
End If
On Error GoTo 0
End Function

when I create or open a defect and click on the button. it prompts the message 2 times. if I do it from grid view it happens only once.

Is this per design? Why? and how does one only trigger the button once so the grid and detail view work the same?