Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP forum
Suggested answer

Field Level Security

Posted on by 355

When bringing up a batch, the customer is having issues where some users are accidentally hitting the delete and removing the transaction from the batch - I went to Field Level Security and disabled the Delete button, which works fine until the user scrolls thru the transactions then the Delete button is enabled again - I cannot disable the arrow buttons on the screen as the users need to scroll through the transactions - not sure what I am missing

Thanks 

pastedimage1648643643208v1.png

Categories:
  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,833 Moderator on at
    RE: Field Level Security

    I am the original creator and developer of Field Level Security.

    The disable or hide options in Field Level Security are implemented when a window is opened. If there is code on the window that will enable or show the field again that runs after the window is opened it can override what Field Level Security does.

    In this case the warning before or password before modes can be used to block the use of that field/button.

    Also, Field Level Security cannot capture modal dialogs and so it could not prevent deletion using the Save, Delete, Cancel modal dialog.

    However, GP Power Tools - Developer Tools module can run triggers after the appropriate events to disable or hide the delete button after it has been enabled again to ensure it stays disabled.

    It can also intercept the modal dialog (something Dexterity natively cannot do), it and prevent the Delete option being used.

    See this similar example:

    winthropdc.wordpress.com/.../

    What you want can be created in a few minutes with GP Power Tools and would not need any separate development tools, no deployment steps and no upgrading when you change GP version.

    If you start a trial period, I would be happy to help you create the code you need with a conference call.

    Kind regards

    David Musgrave

    Original Developer of Field Level Security

  • Suggested answer
    RE: Field Level Security

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Product updates

Dynamics 365 release plans