4 Replies Latest reply on Jan 23, 2013 12:52 PM by DavidJondreau

    How do I stop a record from being deleted

    sarfaraz

      Apologies in advance if this is a really stupid question, but I've tried hard to look for an answer, I promise...

       

      How can I trigger a check when a record is being deleted and veto the deletion if certain conditions are not met? I know I can simply have a button and do the check myself before deleting the record, but is there any way to do this at the data validation level ?

       

      TIA

       

      Sarfaraz

        • 1. Re: How do I stop a record from being deleted
          ErikWegweiser

          Obviously, as with many things FileMaker, there can be several approaches.

           

          One, possibly simplest, is to use the native security / privileges capabilities.

           

          For any privilege set you wish to disallow the ability to delete a record in a given table, configure the Custom privileges of that table, specifying the "Delete" option to be "limited..." with the formula being something like:

           

          getasboolean( deletable_flag )

           

          where the field, deletable_flag, may be a boolean result calculation that takes into account all of the conditions that make a record deletable. If all the conditions are met, the result is '1' (deletable) otherwise, the result is '0' (not deletable). The formula above will allow the record to be deleted only if deletable_flag boolean true.

           

          Or instead of using deletable_flag field, you could just use some othrer direct formula that produces a boolean result (1 always makes it deletable).

           

          You must do this for each privilege group where deletion is to be prevented, but each privilege group could have a different formula determining conditions allowing the record to be deleted.

          Also remember you must test this as a user of a privilege group other than [full access].

          • 2. Re: How do I stop a record from being deleted
            DavidJondreau

            Security privileges are the most secure, but also the most work. Personally, I like using custom menus. Attach the a delete script to the Delete menu item and do your check in the script. Or, if in 12, make the appearance of the delete item conditional.

            • 3. Re: How do I stop a record from being deleted
              Stephen Huston

              Nitpicking semantics note regarding "Or, if in 12, make the appearance of the delete item conditional":

              • If using custom formatting on a delete button, Sarfaraz will still need the script to perform the check if deletes are not controlled by permissions -- even an invisible button can run a script if clicked by accident when you can't see it.

               

              Another thought for Sarfaraz: if permissions are relied on but your running a delete script, don't set the script to run with full permissions, or they can't stop the delete when they should.

              • 4. Re: How do I stop a record from being deleted
                DavidJondreau

                No, I'm referring to the ability to make a menu item appear or not by calculation in a custom menu. Not a button.