6 Replies Latest reply on Jul 21, 2016 11:45 AM by philmodjunk

    How to prevent a record from being unintentionally edited

    hangry

      How can I prevent a record from being unintentionally edited after it has been saved?

       

      My layout has about a dozen controls on it, text boxes and popup menus.

       

      Is there a way to write script that will change the Field Entry, Browse Mode property of each control from yes to no once the record is saved, then add an "Edit" button that changes it back if the user wants to edit the record?

       

      Thanks

        • 1. Re: How to prevent a record from being unintentionally edited
          jbrown

          Howdy.

          THere's no way to change the edit functionality of a field other than layout mode.

          You can, however, create workflows that keeps fields from being edited unless it is an intentional act.

           

          Many developers make two layouts: a read only and a edit layout. They can be exactly the same or slightly different. The read-only has uneditable text. The user presses an "Edit" button on this layout and it opens a new window, the edit version of this layout. That is a deliberate act, and is part of what you'd like.

           

          The other option, if you're using FM 13 or above is to use popovers. You can have a popover on the layout with the same fields, editable. That again is a deliberate act.

           

          In either case, you want to explore the idea of record-locking. If user A is editing record 4, and user B wants to edit it, FileMaker prevents that from happening. User A has the record locked when changing data. It is only when the record is committed does User B have access to it.

          Typically, I think, developers use that Edit button script to check to see if the record is already in use by someone else (locked) and doesn't allow the second user to try to edit it.This same edit button also locks the record for the user before editing. And at the end of the editing process, the record is committed: data is saved to the server and the record is available for other people to use.

           

          I'll put together a quick demo showing these.

          • 2. Re: How to prevent a record from being unintentionally edited
            philmodjunk

            You can also use Manage | Security to implement record level access control. For example, I created a system for invoicing with a field that changes to "printed" once the invoice has been printed and a copy handed to the customer. At that point, we needed to prevent users from modifying the invoice record now that it had been printed.

             

            I went into Manage security, edited the privilege set and selected "custom privileges". I selected the Invoices table, selected "limited" from the edit drop down and entered this lock expression:

            Status ≠ "Printed"

             

            For users with this privilege set, changing the status field to "Printed" locks the record and it can no longer be edited. If I wanted to unlock a record, I could use a "run with full access" script to change the value of the status field or put the status field in a related table so that editing the status field is allowed even when the rest of the fields cannot be edited.

            • 3. Re: How to prevent a record from being unintentionally edited
              hangry

              Thank you. I think we are going to try the alternate, editable layout.

              • 4. Re: How to prevent a record from being unintentionally edited
                alquimby

                There's also Layout Mode, Layouts > Layout Setup... where you can uncheck "Save Record Changes Automatically." Of course, this brings a prompt every time you leave a record after making changes, which can be a pain, but does reduce the chance of a record being edited "unintentionally."

                • 5. Re: How to prevent a record from being unintentionally edited
                  DavidTinoco

                  One way I've done it is define the table privileges for editing with a condition like, records can be edited when "$$GLOBALVARIABLE = 1"; and then use a script to either set or clear this variable. Or you could do it based on a status field in the record, etc.

                  • 6. Re: How to prevent a record from being unintentionally edited
                    philmodjunk

                    Both methods can work. Just keep in mind that interface based methods put entire responsibility for controlling access on you the developer. Record Level Access control, on the other hand "locks down" access no matter what layout is used to access the data.

                     

                    Sent from my iPhone