Prevent mass deletes?

FlowerBizFlowerBiz Member Posts: 34
I searched for this and could not find any relevant posts, which is surprising because I can't be the first to try to stop this behavior.

I have a form in which I need to allow a user to modify, insert, and delete records. But what I don't want to allow is the user selecting all records at once and then pressing F4 or choosing delete. I don't see a way to stop this in the OnDelete trigger yet still allow a single row to be deleted.

Am I missing the obvious?

Thanks.

Comments

  • SavatageSavatage Member Posts: 7,142
    Does this happen by accident but it's too late when they realize what they have done?

    Do you want a second message?
    Usually when you hit F4 you get the pop-up "Delete Selected Lines" (Yes/No) message.
    You can add a second saying "Are you really sure you want to do this!" (Yes/No) with default on NO using a confirmation on ondelete trigger of the table.

    We do this for PO's

    OnDelete()
    PurchSetup.GET;
    IF PurchSetup."Double Delete Warning" THEN BEGIN
    IF NOT CONFIRM('ARE YOU REALLY SURE YOU WANT TO DELETE THIS ORDER?',FALSE)
    THEN ERROR('');
    END;

    else it's hard to graps how to allow deleting but not multiple line deleting. :-k
  • matttraxmatttrax Member Posts: 2,309
    Could you so a SETSELECTIONFILTER and get the count? Also, for most list forms you shouldn't be allowed to delete anyway.

    You can also add code to the OnOpenForm to check if it is being run in lookup mode. If it is you can set editable to false.
  • SavatageSavatage Member Posts: 7,142
    Yeah! is it an editabel list form? Can you explain your scenario?
  • FlowerBizFlowerBiz Member Posts: 34
    Savatage wrote:
    Yeah! is it an editabel list form? Can you explain your scenario?

    Yes, it is an editable list form (or should I say tabular form?). The customer wants to see everything at a glance in a "spreadsheet" form and then make changes as necessary, including additions and deletions. The problem is that some users have learned how to select all rows in the table filter form (for instance) and press delete to clear their previous filter rows. I had one user already do this on the list form. Thankfully I had full change log enabled on every field so I was able to rebuild the data with minimal delay. I know this will happen again and would like to easily prevent it. I realize I can disable deletion on the form and then add a "delete" button that only deletes the current row, and that may be what I end up doing but I'd like to hear how others have tackled this. I would like to think that it has already been thought of by the developers, since standard Navision has many forms that are essentially editable lists (code maintenance, detail line entry subforms, etc.).
  • SavatageSavatage Member Posts: 7,142
    You could set "DeleteAllowed" property of the form to NO.

    Add a boolean field to this tabular form called "DELETE" that they can check off per line.
    then add a button on the bottom with code ..."Clear Deleted Orders" or whatever it is they are deleting.
    it runs delete code thru the table filtering on this new field.

    you can even filter that form so once the delete is checked it gets hidden from that tabular form (Set RunFormView = deleted(no)).
    and have another form that shows the orders that have been marked for deletion that someone can review to make sure it actually should be deleted (RunFormView = deleted(yes). if not they can uncheck it to bring it back, else if it's all good to kill they can run the button/function to delete the orders.

    we do something similar for our regular orders & internet orders. we have two forms.RunFormView set to internet order yes & the other to no. makes it easy to seperate visually.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    FlowerBiz wrote:
    ...I'd like to hear how others have tackled this. ...


    We call it "User Training". :whistle:
    David Singleton
Sign In or Register to comment.