I have had this question in the past, though usually with the Save button, wanting to be removed from this type of window.
This prompt is a system dialog and is not a Dexterity form. Even though the dialog box can be created from Dexterity, you cannot address, trigger, or control this kind of dialog from Dexterity. Therefore, Dexterity and Field Level Security cannot control system dialogs. (Field Level Security is written in Dexterity.)
From what I’ve found and understand, the only alternatives are to either use a Dexterity Trigger on the Delete_Record form level procedure or use the Delete Record field script to stop the Delete.
The other option is to use the Window_BeforeModalDialog() event in Microsoft VBA to always answer Cancel when the users are prompted with the system dialog and to then disable the Delete button.
For example, using VBA, I added the Payables Transaction Entry window to the Visual Basic Editor, then in VBA, for this window, I went under the Window.BeforeModalDialog event and added the following code:
Private Sub Window_BeforeModalDialog(ByVal DlgType As DialogType, PromptString As String, Control1String As String, Control2String As String, Control3String As String, Answer As DialogCtrl)
'Verify which modal dialog is currently displayed
If PromptString = "Do you want to save changes?" Then
'Close dialog window by selecting the Cancel button
Answer = dcButton3
End If
End Sub
Saving changes and going back into Dynamics GP, if I create a new transaction I’m able to save it, or if I make changes to an existing transaction I can save it.
However, if I make a change to an existing PM transaction and then click the X to close the window without clicking Save, it won’t close the window because the VBA code is triggering the ‘Cancel’ button with the dcButton3 value, so the user cannot use the Delete option through this dialog box.
dcButton2 indicates the Delete button and dcButton1 is the Save button in this dialog box, so you could set it as you wish.
You can try this and see if it works for you.......others in the Community may have better options.
Thanks