March 29, 20178 yr Hello to all, I have a database and I want to block modification of the fields if a given variable is not = 1. can i do this? i have create a button that change the variable from 0 (non modifiable) to 1 (modifiable) but if the variable is 0 i want that fields are only reading. i use Filemaker Pro 15 for mac thanks Andrew
March 29, 20178 yr Hi Andrew You can set OnObjectModify (and OnObjectKeystroke if you like) Script Triggers on the fields that you want to lock, to run a script along the lines of the below. That will reject the input if the $$lockvariable is set to 0 If [ $$lockvariable = "0" ] Exit Script [ Result: 0 ] End If As an extension, in one of our solutions we show an error panel, that is just a rectangle with some text in it that is the frontmost layer of the layout, and we use an OnTimer script to hide it after a couple of seconds. This explains to the user why their input is not appearing, but doesn't require them to acknowledge it. If [ $$lockvariable = 0 ] Set Variable [ $$showInputError; Value:"Y" ] // the $$showInputError variable is used to show/hide the rectangle with text in it Install OnTimer Script [ “Clear Input error”; Interval: 2 ] // this script sets $$showInputError back to 'N' after 2 seconds, which hides the rectangle again Refresh Window Exit Script [ Result: 0 ] End If The 'Clear Input Error' script needs to both change the variable $showInputError back to "N" and stop the OnTimer script otherwise it keeps running every 2 seconds. That script looks like this. Set Variable [ $$showInputError; Value:"N" ] Refresh Window Install OnTimer Script [ ] Hope that helps Edited March 29, 20178 yr by rwoods
March 29, 20178 yr Author Hello. I tried to follow your example and I managed to set up the script. Thanks again.
March 29, 20178 yr 11 hours ago, pomilpetan said: I want to block modification of the fields if a given variable is not = 1. The simple method would be to allow users to edit records only when the variable = 1 (in users privilege set). However, I would ask why you need this - because any limitation that depends on the value of a variable can be circumvented by the user.
March 30, 20178 yr Author 12 hours ago, comment said: The simple method would be to allow users to edit records only when the variable = 1 (in users privilege set). However, I would ask why you need this - because any limitation that depends on the value of a variable can be circumvented by the user. The person who asked me the database has noticed that often unintentionally wrote in the fields instead of doing a search or changed field by deleting the content. so at least you can only read without changing the data unless authorized to do so.
Create an account or sign in to comment