Is it possible to lock records to prevent accidental changes?
It is possible to implement the security within filemaker to allow or dis-allow editing of a record based on a field value. For example - you can setup a field called "Locked" and set it to 1 for locked or empty for unlocked. Then setup you security to allow "Edit" using "Limited" settings, using the "Locked" field as the boolean 1 or 0.
This can be implemented on a record level "Edit", or even on individual Field editing level.
If you want the user to be able to "un-lock" the record, they can only do so via a script with full access privileges.
If you can precisely define "accidental changes" you should look first to the custom record level edit...limited calculation in the users privilege set. Data integrity should be enforced at the data layer level. Trying to enforce it at the UI level can be done but is usually problematic.
You can certainly lock down fields from being entered while on a layout. Go into layout mode, select the fields you want locked down, and go to the inspector. In the data tab, unclick the "Field Entry in Browse Mode" box (about halfway down the inspector).
This will prevent users from accidentally changing records.
WE could go higher into the security settings by changing privilege sets to not allow editing of any specific fields, but that might be too much at the moment.
One method is to have 2 layouts. One for viewing the data and one for making changes. A button could switch the user between layouts. All fields on the viewing layout would have the Inspector | Data | Field entry Browse Mode unchecked.
Thanks for your answer!
That is great but I want the user to be able to modify "locked" fields. I would need a "lock/unlock" button. That is why security settings won't work because user need to modify/create/delete rights.
I need our user to be able to modify record so I can't deny modifications for those users.
If you have a lock/unlock button that anyone can toggle its the same as letting everybody edit everything anytime and only provides a nuisance action that will not actually enforce data integrity.
instead of another layout, you could explore using a popup button with all fields you would need to edit within. turn off "Field Entry in Browse Mode" as stated above or use merge fields on main layout.
You are right but that's what the client wants.
There is too many fields to put them in a popup button. For now, the only option is to have to different layouts.
So, create the 1st layout with all fields set with Browse Mode Field Entry unchecked. This will be your "locked" layout. The button on that layout would say "Unlock". That button would take the user to a duplicate layout with all fields set with Browse Mode Field Entry checked. This will be your unlocked layout. The button on this layout will say "Lock", which will take the user back to the locked layout. As far as the user sees, the only difference between the layouts is that the button changes from Lock to Unlock. You may also want to have a huge text message stating "LOCKED" or "UNLOCKED" so they will know what screen they are using.
As fellows have mentioned already, there are any number of methods of locking records, layouts, fields, etc. What I have found is that through a little bit of creative scripting, one can also lock records or the content of records (fields) so that everyone may be able to see the field/record, but only the user who created the content of the record can modify it. This works quite well in situations where the user who creates the record does not want other users "accidentally" modifying or deleting records.
This also works very well for those occasional users who want to do a find and forget to click the FIND before they start typing, release it is not working, then jump out of the record to click the Find button not realizing they have just modified an existing record. This happens all too often when the "boss" has permissions but does not use the solution often enough to be familiar with all the functions. If you follow my meaning . . been there, done that.
Yes I know exactly what you mean, been there too!
Someone suggest me to uncheck "Save record changes automatically" in the Layout Setup. Like that, each modification to an existing field will ask to save. Works perfectly for us.
You have already been provided some options for doing what you want. There are some other ways, not the best, but they are alternatives.
1) To make double sure that unintended changes to a record are not made, set an OnCommitRecord script trigger on the layout. Any time someone changes the record and tries to save it (click on the background, change records, etc) your OnCommitScript could check to see whether it is allowed or not. Execute a Revert Record in the script and exit the script with a value of "False" or 0 to prevent the action from completing.
2) You could also use the Hide When option in FM13 and FM14. Create two copies of the field that you want to allow people to modify, one with Browse allowed and the other without. Give the fields the opposite hide conditions, probably based on a global field or variable (I prefer a field since you do not have to do a Refresh Object/Layout). So one field will have a hide condition of TO::gField = X, and the other will have the opposite value (not (TO::gField = X)). Simple and effective. It minimizes the number of layouts.
Thanks for your answer, very useful stuff!
I had try to solve the problem and finally found a way.
I put the solution here:
The way of lock or unlock record or field@@
Retrieving data ...