3 Replies Latest reply on Nov 30, 2012 6:55 AM by philmodjunk

    Change field properties using script

    EwanMcallister

      Title

      Change field properties using script

      Post

           I need to change the properties of a field using a script. If a field value is equal to a specific value then I want to change, ideally, the visibility and/or the field entry mode of another field to either allow or disallow entry or to change visibility. I am relatively new to FM so maybe this is a simple task.

        • 1. Re: Change field properties using script
          philmodjunk

               You canot dynamically change the properties of a layout's field object via a script. You'll need to use other methods to achieve these results.

               See this demo file for a list of options for controlling the visibility of a layout object: https://www.dropbox.com/s/8levaz6deiyzjr8/LayoutObjectVisibilityControlDemo.fp7

               Controlling field accessibility can be done with script triggers or you can set up Record Level Acces controls to control access to a specific record on a record by record basis. You can also use validation rules that reject any changes to a record if a validation calculation you create does not evaluate to a "True" value.

                

          • 2. Re: Change field properties using script
            EwanMcallister

                 Thanks for the reply, I get the visibility bit but cant seem to get how to control say a fields entry mode. Say I dont want an entry to a field unless a condition is met, how can I inhibit entry to the field until the condition is met.

                  

                  

            • 3. Re: Change field properties using script
              philmodjunk

                   Record Level Access Control is the most secure method as the settings used there keep a user from accessing an unauthorized field on all your layouts from a single setting, but such settings lock the user out of an entire record--not a specified field. This method works well, however, if you move the field or group of fields into a related table such that selectively denying access at the record level denies access for your field or group of fields.

                   An OnObjectEnter Script trigger, on the other hand can perform a script that checks the condition that determines field accessibility and uses go to field, go to next field or go to object to move the focus back out of the field if the user is not permitted to access the field. There are two drawbacks to this approach: 1) you have to set this up on every layout where you need such controlled access.  2) Drag and drop can still be used to modify data in the field as drag and drop does not trip the OnObjectEnter trigger. Thus, this method is best for preventing "accidents" than for providing a fool proof barrier against modifying the contents of the field.

                   If you take another look at the demo file, the invisible tab control method may be used by placing fields and other layout objects in both of two tab panels, but using field behavior to deny access to the field on one of the two panels. Then the same scripted methods that can make layout objects appear and disappear can be used to select between the panel with locked and unlocked fields. This has the same need to set it up on possibly multiple layouts, but defeats "drag and drop" efforts to alter the field.

                   Another option worth considering is to set up a validation rule on the field that rejects all changes to the field if the conditions controlling access do not permit access to the field. This permits the user to access the field, but then rejects any changes made to it. Since this setting is made at the data level, it will control changes to the field on all layouts from a single setting. I often use this setting in conjunction with one of the previous two settings as an "insurance policy" that will protect the field contents even if I accidentally leave open a way around my field access control methods.