Example: Controlling User Permissions

This example demonstrates how you can prevent members of specific user groups from performing an action.

The code allows a user to replace a defect field value only if the user belongs to the Admin user group.

Add the code to the ActionCanExecute event procedure so that the check is performed when a user attempts to execute an action.

Function ActionCanExecute(ActionName)
        ' Initialize the function's return value
	' to avoid unpredictable behavior.
        ActionCanExecute = False 
        On Error Resume Next
        If ActionName = "UserDefinedActions.BugReplaceAction1" _
            And Not User.IsInGroup("Admin") then
            ActionCanExecute = False
            msgbox "You do not have permission to perform this action"
            ActionCanExecute = True
        End If
        PrintError "ActionCanExecute"
        On Error GoTo 0
End Function