4 Replies Latest reply on Apr 18, 2014 8:28 AM by philmodjunk

    Script to make fields non editable at periodic intervals

    JohnDee

      Title

      Script to make fields non editable at periodic intervals

      Post

           Is this a common practise? I way toying with this idea because really after a while records should be filled in and not prone to the old accidental edit. 

            

        • 1. Re: Script to make fields non editable at periodic intervals
          philmodjunk

               To make an entire record "read only" is best done via account privileges set for the user in Manage | Security. You can set up a "lock expression" that determines which records are editable.

               See "Editing record access privileges" in FileMaker Help and check out this particular sub section: "Entering a formula for limiting access on a record-by-record basis" for a description of how to set this up.

          • 2. Re: Script to make fields non editable at periodic intervals
            WBSimon

                 I know this is kind of vague . . . and I haven't completely worked this out but it may send you in the right direction . . . 

                 I make fields un-editable by creating a calculated field of the field that I want to protect. Maybe combine that with the hide object option to un-hide the edit field after an amount of time.  If  ( Get ( CurrentTimeStamp ) >  (RecordCreateTimeStamp + 60 mins) ).

            • 3. Re: Script to make fields non editable at periodic intervals
              JohnDee

                   Hey Brent, thanks for that! Esp. the if clause, great idea. I am trying to figure out what you are doing but I am not 100% with you on it. I was thinking of overlaying two fields, one editable the other not, then hiding/showing the non editable field with a condition, say if the field has been not empty for X amount of time show the non editable, and of course the opposite for the editable one, to hide it after said time since it was edited. Which is all rather convoluted to be honest with all the double layout field elements, but what can you do. Surely a make non editable after x time inbuilt fm option would be great, but you can't really blame them for not being there as you have other ways to implement it I guess. 

                    

                   ps. cool avatar, twas one of my first lps, got it from a used store, what a a band...  

              • 4. Re: Script to make fields non editable at periodic intervals
                philmodjunk

                     The layered fields makes sense if you only want to limit access to a few fields of the total record and only on one or two layouts.

                     The method I described works well to lock down all the fields in the record with a single setting such that it controls access across all layouts in your database.

                     There are also methods that use script triggers that move the focus back out of the field if the user or the circumstances are such that they aren't permitted to make changes to the field. This is also layout specific, though less complex than layered fields. It also can be by-passed by drag and drop in some circumstances.

                     Field Validation rules can also be used to selectively lock down individual fields. Like a lock expression set in Manage | Security, this method locks the field against all attempts to change the field and across all layouts where you might place that field. But it allows the user to attempt the change and then pops up an error message requiring them to revert the change after they try to exit the field. That's not really user friendly but it often makes a good "insurance policy" when using layout based access control methods such as script triggers just to make sure that users can't find a way around your layout based access control.